import pylab
-def generate_data(stream, N, ordered=False):
+def generate_data(generator, stream, N, ordered=False):
print >> sys.stderr, 'generate %d data points (ordered? %s)' % (
N, ordered)
stream.seek(0)
stream.truncate()
- args = ['./data.py', str(N)]
+ args = [generator, str(N)]
if ordered:
args.insert(1, '--ordered')
q = subprocess.Popen(args, stdout=stream)
assert status == 0, status
return stop - start
-def run_tests(executable, stdin=True, data_file=None, ordered=False,
- repeats=10, max_time=1e2):
+def run_tests(executable, stdin=True, generator='./data.py', data_file=None,
+ ordered=False, repeats=10, max_time=1e2):
times = {}
prev_time = 0
N = 2
print
ts = numpy.zeros((repeats,), dtype=numpy.double)
for i in range(repeats):
- generate_data(data_file, N, ordered=ordered)
+ generate_data(generator, data_file, N, ordered=ordered)
ts[i] = run_test(executable, stdin, data_file.name)
times[N] = ts
prev_time = ts.mean()
usage='%prog [options] executable', epilog=__doc__)
p.add_option('-s', '--stdin', dest='stdin', default=False,
action='store_true', help='Use the stdin executable syntax.')
+ p.add_option('-g', '--generator', dest='generator', default='./data.py',
+ help='Executable generating the random source (%default).')
p.add_option('-r', '--repeats', dest='repeats', default=10, type='int',
help='Number of repeats to run at each N (%default).')
p.add_option('-m', '--max-time', dest='max_time', default=1e2,type='float',
kwargs = {
'executable': executable,
'stdin': options.stdin,
+ 'generator': options.generator,
'data_file': data_file,
'repeats': options.repeats,
'max_time': options.max_time,