Message11662

Author jeff.allen
Recipients jeff.allen, zsd
Date 2017-11-19.22:23:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511130203.01.0.213398074469.issue2643@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-11-19 22:23:23jeff.allensetmessageid: <1511130203.01.0.213398074469.issue2643@psf.upfronthosting.co.za>
2017-11-19 22:23:23jeff.allensetrecipients: + jeff.allen, zsd
2017-11-19 22:23:22jeff.allenlinkissue2643 messages
2017-11-19 22:23:22jeff.allencreate