[Tutor] time taken to execute certain task

ALAN GAULD alan.gauld at btinternet.com
Thu Mar 17 10:41:54 CET 2011


Profiling is really intended to profile a complex set of operations 
not a single statement, for that timeit() would be a better choice.

However in this case, it may be that the time is so low it simply 
doesn't register. Have you already imported math for example? 
In which case you are effectively profiling a single if statement...


 
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/





________________________________
From: tee chwee liong <tcl76 at hotmail.com>
To: alan.gauld at btinternet.com; tutor at python.org
Sent: Thursday, 17 March, 2011 9:06:56
Subject: RE: [Tutor] time taken to execute certain task

 hi, 
 
i used profiler. but it gives 0 sec? is this expected? tq
 
>>> profile.run('import math')
         3 function calls in 0.000 CPU seconds
   Ordered by: standard name
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 :0(setprofile)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 profile:0(import math)
        0    0.000             0.000          profile:0(profiler)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110317/e0cf9b03/attachment.html>


More information about the Tutor mailing list