As implemented, time.clock() is giving you wall-clock time. I'm sure that's the best we could do at the time it was written (looks old).
Interesting question. If you want a work-around, I found this worked:
>>> from java.lang.management import ManagementFactory as MF
>>> tb = MF.getThreadMXBean()
>>> tb.isThreadCpuTimeSupported()
True
>>> tb.getCurrentThreadCpuTime()
3421875000L
>>> tb.getCurrentThreadCpuTime()*1e-9
3.484375
>>> tb.getCurrentThreadCpuTime()*1e-9
3.5
>>> tb.getCurrentThreadCpuTime()*1e-9
3.515625
It might be useful to re-implement time.clock() this way, if it is available on all major platforms. |