Re: [Tutor] get cpu time used by a python script

2007-02-07 Thread Kent Johnson
Kim Branson wrote:
> Hi Chris,
> 
> that seems to be exactly what i need.

The resource module is Unix-only, not cross-platform as you originally 
requested.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-07 Thread Alan Gauld

"Kim Branson" <[EMAIL PROTECTED]> wrote

> whats the simplest cross platform way of getting the cpu time used 
> by
> a python script?

Does the os.times() function give you enough?
Its not strictly cpu time...

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-06 Thread Kim Branson
Hi Chris,

that seems to be exactly what i need.

Cheers

Kim



 >>> import resource
 >>> def cpu_time():
... return resource.getrusage(resource.RUSAGE_SELF)[0]
...

Now try this out

 >>> def f():
... for i in xrange(10):
... pass
...
 >>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.008001
 >>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.012001

On Feb 6, 2007, at 8:58 PM, Christopher Lucas wrote:

> python/python/545797?page=las

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-06 Thread Christopher Lucas
This link may be of use to you. http://www.gossamer-threads.com/lists/ 
python/python/545797?page=last

-Chris


On Feb 6, 2007, at 9:37 PM, Kim Branson wrote:

>
> The time in used by the cpu for the execution of the script, rather  
> than the wall clock time.
>
> CPU execution time for program = Clock Cycles for program x Clock  
> Cycle Time
>
> But i'm interested in the cpu cycles used purely for the python  
> app, regardless of what other processes may be running.
>
> kim
>
>
> On Feb 6, 2007, at 8:20 PM, Christopher Lucas wrote:
>
>>
>> On Feb 6, 2007, at 9:14 PM, Kim Branson wrote:
>>
>>> Hi
>>>
>>> whats the simplest cross platform way of getting the cpu time  
>>> used by
>>> a python script?
>>>
>>> Kim
>>
>> What do you mean by "cpu time", Kim?
>

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-06 Thread Christopher Lucas

On Feb 6, 2007, at 9:37 PM, Kim Branson wrote:

>
> On Feb 6, 2007, at 8:20 PM, Christopher Lucas wrote:
>
>>
>> On Feb 6, 2007, at 9:14 PM, Kim Branson wrote:
>>
>>> Hi
>>>
>>> whats the simplest cross platform way of getting the cpu time  
>>> used by
>>> a python script?
>>>
>>> Kim
>>
>> What do you mean by "cpu time", Kim?
>
> The time in used by the cpu for the execution of the script, rather  
> than the wall clock time.
>
> CPU execution time for program = Clock Cycles for program x Clock  
> Cycle Time
>
> But i'm interested in the cpu cycles used purely for the python  
> app, regardless of what other processes may be running.
>
> kim
>

I'm not sure, but this link may be of use. http://www.gossamer- 
threads.com/lists/python/python/545797?page=last

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-06 Thread Kim Branson

The time in used by the cpu for the execution of the script, rather  
than the wall clock time.

CPU execution time for program = Clock Cycles for program x Clock  
Cycle Time

But i'm interested in the cpu cycles used purely for the python app,  
regardless of what other processes may be running.

kim


On Feb 6, 2007, at 8:20 PM, Christopher Lucas wrote:

>
> On Feb 6, 2007, at 9:14 PM, Kim Branson wrote:
>
>> Hi
>>
>> whats the simplest cross platform way of getting the cpu time used by
>> a python script?
>>
>> Kim
>
> What do you mean by "cpu time", Kim?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get cpu time used by a python script

2007-02-06 Thread Christopher Lucas

On Feb 6, 2007, at 9:14 PM, Kim Branson wrote:

> Hi
>
> whats the simplest cross platform way of getting the cpu time used by
> a python script?
>
> Kim

What do you mean by cpu time, Kim?

-Chris
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor