From: W. Trevor King Date: Mon, 25 Oct 2010 14:03:24 +0000 (-0400) Subject: Add --generator option to src/sorting/scaling.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bab73ff6b29c9398d3a5fb1deddd7826ba414480;p=parallel_computing.git Add --generator option to src/sorting/scaling.py. --- diff --git a/src/sorting/scaling.py b/src/sorting/scaling.py index c553ee4..712afbb 100755 --- a/src/sorting/scaling.py +++ b/src/sorting/scaling.py @@ -18,12 +18,12 @@ matplotlib.use('Agg') # select backend that doesn't require X Windows 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) @@ -49,8 +49,8 @@ def run_test(executable, stdin=True, data_filename=None): 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 @@ -58,7 +58,7 @@ def run_tests(executable, stdin=True, data_file=None, ordered=False, 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() @@ -76,6 +76,8 @@ def main(argv=None): 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', @@ -91,6 +93,7 @@ def main(argv=None): kwargs = { 'executable': executable, 'stdin': options.stdin, + 'generator': options.generator, 'data_file': data_file, 'repeats': options.repeats, 'max_time': options.max_time,