up [pdf]
from rsf.proj import *

# Generate random data
######################
Flow('rand',None,
     'spike n1=524288 | noise rep=y type=n seed=2012')

prog = Program('sorting.c')

sort = 'slow'

# !!! UNCOMMENT THE NEXT LINE !!!
# sort = 'quick' 

# Sorting movie
###############
Flow('movie','rand %s' % prog[0],
     '''
     window n1=200 | 
     ./${SOURCES[1]} movie=$TARGET type=%s
     ''' % sort,stdout=0)
Plot('movie',
     '''
     graph symbol=o title="%s Sort" wantaxis=n symbolsz=5
     ''' % sort.capitalize(),view=1)

# Sorting cost
##############
na = 8192
costs = []
for n in range(5):
    na *= 2
    cost = 'cost%d' % n
    Flow(cost,'rand  %s' % prog[0],
         '''
         window n1=%d | 
         ./${SOURCES[1]} type=%s
         ''' % (na,sort))
    costs.append(cost)
Flow('cost',costs,
     'cat axis=1 ${SOURCES[1:5]} | put o1=14 d1=1 unit1=')

Result('cost',
       '''
       math output="log(input)/log(2)" |
       graph title=Cost 
       label1="log(N)" label2="log(CPU Cycles)" 
       ''')

End()

sfspike
sfnoise
sfwindow
sfgraph
sfcat
sfput
sfmath