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 <tc...@hotmail.com>
To: alan.ga...@btinternet.com; tutor@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)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to