[Tutor] how to convert usec/pass to seconds

Surya K suryak at live.com
Sat Jan 28 19:14:15 CET 2012


I am actually using a activestate wrapper for calculating execution time of my program.

This is the code 
#!/usr/bin/python# A simple wrapper for the timeit module.import timeit
def Timeit(func,number=10000,module="__main__"):    """ A wrapper which can    be used to time any function """
    name = func.__name__    t = timeit.Timer("%s()"%name, "from %s import %s" % (module, name))    return "%.2f usec/pass" % (1000000*t.timeit(number=number)/number)
if __name__=="__main__":
    from program import*
    # Using wrapper    print Timeit(main)    # Directly using timeit    t = timeit.Timer("main()", "from __main__ import main")    print "%.2f usec/pass" % (1000000*t.timeit(number=10000)/10000)

So, this module is showing my execution time in usec/pass.
I tested it for a puzzle and that showed me around 1385.33 usec/sec..However, as its from facebook hackers cup where I got a penalty time of 28.32.00 (not exactly, forgot).. 
what units facebook was following.. If I had to change those usec/pass units to seconds, what I have to use.
can anyone tell me?


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120128/54e3608a/attachment.html>


More information about the Tutor mailing list