# L-29 MCS 260 Fri 2 Nov 2007 : timetosort # # This program illustrates how to time the # sort of lists. The optional command line # argument is the length of the list to sort. import time import sys from random import gauss if len(sys.argv) < 2: n = input('Give #elements : ') else: n = int(sys.argv[1]) r = range(0,n) L = map(lambda i: gauss(0,1),r) start_time = time.clock() L.sort() stop_time = time.clock() elapsed = stop_time - start_time print 'sorting %d floats' % n \ + ' took %.3f seconds ' % elapsed