Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
My "main" routine for Project Euler. Runs that program specified by arg1, times the execution and prints the answer and timing The timer is rather too coarse and the details (real time vs. CPU time) differ from Linux to WIndows.
from time import clock
if __name__ == "__main__":
import sys
print "args=", sys.argv
x="from " + sys.argv[1] + " import main"
print x
exec x
tstart=clock()*1000
answer=main()
tend=clock()*1000
print "answer=", answer
print "tstart=", "%e" % tstart, "tend=", "%e" % tend
print "runtime(CPU milliseconds)=", str(tend-tstart)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment