Finding cpu time spent on my program
Carl J. Van Arsdall
cvanarsdall at mvista.com
Mon Feb 5 14:32:59 EST 2007
kyosohma at gmail.com wrote:
> On Feb 5, 2:37 am, "jm.sur... at no.spam.gmail.com" <jm.sur... at gmail.com>
> wrote:
>
>> I am trying to measure the time the processor spends on some
>> operation, and I want this measure to not depend on the current load
>> of the machine. But doing the following prints different values each
>> time a run.
>>
>> import time
>> c1 = time.clock()
>> for x in xrange(0xFFFFF): pass
>>
>> c2 = time.clock()
>> print "Time spent is %f" % (c2-c1)
>>
>> Is there a way to measure the number of cpu cycles spent on my program
>> alone irrespective of the current load etc of the machine.
>>
There's an performance testing suite that you might also find useful.
Check out TAU: Tuning and Analysis Utilities toolkit (simple google
search will take you to the page). You can get some serious numbers
using that thing and they have python support as well as some tools for
automatically profiling an entire application. Check it out.
-carl
--
Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software
More information about the Python-list
mailing list