Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 time.process_time() is constant

I'm usually using time.clock() to measure the time elapsed in a process, to disregard time spent in other processes (so not the 'wall clock').

I see that it is deprecated (because "The problem is time.clock(), since it does two wildly different things depending on the OS"...) and about to be removed in 3.8, and that time.process_time() is to be used instead.

I am currently testing it on Python 3.7.4 (64-bit) for Windows, on Win7 x64, and the returned value of time.process_time() is always the same, thus the elapsed time is always zero.

>>> time.process_time()
>>> time.sleep(3)
>>> time.process_time()
Is that a known issue, or am I doing something wrong? I searched but didn't find anything relevant.

I'm aware that time.clock() was not always returning the process elapsed time in Windows, but may return the actual elapsed time, and that this should mostly be used with Linux implementation. Still, I'm not expecting that new function to return a constant value.
Obviously it doesn't get the same precision as Linux. Using another, more time-consumming task between the measures show a difference.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)