|
Re: extracting a random subset of a vector: msg#00037python.numeric.general
Robert Kern wrote: From the doc of the module 'time': the clock function "return the current processor time as a floating point number expressed in seconds." AFAIK, the processor time is not the time spent in the process calling the function. Or is it? Anyway, "this is the function to use for benchmarkingPython or timing algorithms.", that is, if processor time is good enough, than use time.clock() and not time.time(), irregardless of the system, right? Well, this is what I have in my timing code: # Basic timing functionality # If possible (Unix), use the resource module instead of time.clock() try: import resource def clock(): """clock() -> floating point number Return the CPU time in seconds (user time only, system time is ignored) since the start of the process. This is done via a call to resource.getrusage, so it avoids the wraparound problems in time.clock().""" return resource.getrusage(resource.RUSAGE_SELF)[0] except ImportError: clock = time.clock I'm not about to argue with Tim Peters, so I may well be off-base here. But by using resource, I think I can get proper CPU time allocated to my own process by the kernel (not wall clock), without the wraparound problems inherent in time.clock (which make it useless for timing long running codes). Best, f ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: extracting a random subset of a vector: 00037, Chris Barker |
|---|---|
| Next by Date: | Re: Reshaing continued: 00037, Rob Hooft |
| Previous by Thread: | Re: extracting a random subset of a vectori: 00037, Robert Kern |
| Next by Thread: | Re: extracting a random subset of a vector: 00037, Chris Barker |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |