Created
November 26, 2013 07:26
-
-
Save rdrewd/7654590 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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