Author lemburg
Recipients giampaolo.rodola, lemburg, pitrou, vstinner
Date 2012-03-19.14:14:16
SpamBayes Score 8.46339e-10
Marked as misclassified No
Message-id <>
In-reply-to <>
STINNER Victor wrote:
> STINNER Victor <> added the comment:
>> There's no other single function providing the same functionality
> time.clock() is not portable: it is a different clock depending on the OS. To write portable code, you have to use the right function:
>  - time.time()
>  - time.steady()
>  - os.times(), resource.getrusage()

time.clock() does exactly what the docs say: you get access to
a CPU timer. It's normal that CPU timers work differently on
different OSes.

> On Windows, time.clock() should be replaced by time.steady().

What for ? time.clock() uses the same timer as time.steady() on Windows,
AFAICT, so all you change is the name of the function.

> On UNIX, time.clock() can be replaced with "usage=os.times(); usage[0]+usage[1]" for example.

And what's the advantage of that over using time.clock() directly ?
Date User Action Args
2012-03-19 14:14:17lemburgsetrecipients: + lemburg, pitrou, vstinner, giampaolo.rodola
2012-03-19 14:14:16lemburglinkissue14309 messages
2012-03-19 14:14:16lemburgcreate