Bottom Page

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

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()
0.0936006
>>> time.sleep(3)
>>> time.process_time()
0.0936006
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.
Quote
#2
Obviously it doesn't get the same precision as Linux. Using another, more time-consumming task between the measures show a difference.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Why does time.sleep(wait) add time in python3 ? gerardg 4 515 Apr-28-2019, 06:26 PM
Last Post: gerardg
  time.time wont return a useable number Nyscersul 4 465 Nov-15-2018, 03:08 PM
Last Post: Nyscersul
  Getting error in finding time.time() value in python Lakshana 1 690 Jan-11-2018, 07:07 AM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)