# Rather simple Python time test. # Builds and sorts array(s) of numbers. import time import string def make_num_list(howmany) : mylist = [] i, j, k = 20, 245, 8003 while howmany > 0 : #print str(i) + ' % 20 = ' + str(i%20) mylist.append( (i % 20) + (j * 4023 % 145) + (k * 5671 % 879) ) i += 1 j += 1 k += 1 #print mylist; howmany -= 1; return mylist def add_a_time(times_ref_array) : """Assumes that times_ref_array[0] is a list to which this function shall append the current time for benchmarking, as a floating-point number in seconds (time.clock() )""" times_ref_array[0].append(time.clock()) return def num_list_test(howmany) : times = [] times_arg = [times] add_a_time(times_arg) print 'RUNNING FUNCTION num_list_test(' + repr(howmany) + ')' #times = [time.clock()] #print 'times: ' + str(times(len(times))) print 'times : ' + str(times) mylist = make_num_list(howmany) add_a_time(times_arg) #print mylist add_a_time(times_arg) mylist.sort() add_a_time(times_arg) print mylist add_a_time(times_arg) print 'times : ' + str(times) print 'EXITING FUNCTION num_list_test(' + repr(howmany) + ')\n' #-------------------------------------------------------------- #num_list_test(30) num_list_test(5) num_list_test(500) num_list_test(5000) #num_list_test(20000) num_list_test(50000) #num_list_test(100000)