Added src/sorting/scaling.py to test sort algorithm scaling vs. N.
[parallel_computing.git] / src / sorting / data.py
1 #!/usr/bin/env python
2
3 """Generate random (or ordered) data for sorting.
4
5 Output format:
6
7     # <N>
8     <point 1>
9     <point 2>
10     <point 3>
11     ...
12     <point N>
13 """
14
15 import optparse
16 import random
17 import sys
18
19
20 p = optparse.OptionParser(usage='%prog [options] N_POINTS', epilog=__doc__)
21 p.add_option('-o', '--ordered', dest='shuffle', default=True,
22              action='store_false', help="Don't shuffle the output data.")
23
24 options,args = p.parse_args()
25
26 N = int(args[0])
27 data = range(N)
28
29 if options.shuffle:
30     random.shuffle(data)
31
32 print '# %d' % N
33 print '\n'.join([str(x) for x in data])