kovisoft / slimv

Official mirror of Slimv versions released on vim.org
454 stars 60 forks source link

Use time.process_time() instead of time.clock() with python 3.3 or later #69

Closed Tacumi closed 6 years ago

Tacumi commented 6 years ago

In the Python 3.7 environment, I received a warning of the deprecated function. By adding an if statement, it was fixed with Python 2.7 compatibility.

kovisoft commented 6 years ago

I think time.process_time() is not okay for that purpose, because it returns the CPU time of the current process, so it does not measure the actual time elapsed (it does not include e.g. the time spent in sleep). I suggest using time.perf_counter() instead.

Just check this:

time.process_time(); time.sleep(1); time.process_time()

vs.

time.perf_counter(); time.sleep(1); time.perf_counter()

For me the first one shows the same value before and after the 1 second sleep.