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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Insert a multiple constant value after header in csv file using python shantanu97 1 1,114 Apr-24-2022, 10:04 AM
Last Post: Pedroski55
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,434 Apr-05-2022, 06:18 AM
Last Post: C0D3R

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020