Xpra: Ticket #2178: better monotonic clock for win32

Using QueryPerformanceCounter (windows 2000 and later).



Tue, 26 Feb 2019 06:35:33 GMT - stdedos: cc set


Thu, 20 Jun 2019 06:52:24 GMT - totaamwin32: owner, status changed

Interesting results:

$ python3 -m timeit  "from xpra.os_util import monotonic_time;monotonic_time()"
500000 loops, best of 5: 650 nsec per loop
$ python3 -m timeit  "from xpra.os_util import time;time.perf_counter()"
200000 loops, best of 5: 1.1 usec per loop
$ python3 -m timeit  "from xpra.os_util import time;time.clock()"
C:/msys64/mingw64/lib/python3.7\timeit.py:6: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
  times.  See also Tim Peters' introduction to the Algorithms chapter in
200000 loops, best of 5: 1.76 usec per loop

Thu, 20 Jun 2019 08:02:34 GMT - totaamwin32: status changed; resolution set

python2 doesn't have time.perf_counter, here's the data:

$ PYTHONPATH=../build/exe.mingw-2.7/lib python2 -m timeit   "from xpra.os_util import monotonic_time;monotonic_time()"
1000000 loops, best of 3: 0.577 usec per loop
$ python2 -m timeit  "from time import clock;clock()"
1000000 loops, best of 3: 0.84 usec per loop

r23001 adds a QueryPerformanceCounter implementation.

New data:

$ PYTHONPATH=../build/exe.mingw-2.7/lib python2 -m timeit   "from xpra.os_util import monotonic_time;monotonic_time()"
1000000 loops, best of 3: 0.563 usec per loop
$ PYTHONPATH=../build/exe.mingw-3.7/lib python3 -m timeit   "from xpra.os_util import monotonic_time;monotonic_time()"
200000 loops, best of 5: 1.06 usec per loop

So we lost a tiny bit of performance with python3 (not with python2), but we gained precision.


The python2 time.clock uses QueryPerformanceCounter, but it is deprecated in python3.


Fri, 19 Jul 2019 18:19:16 GMT - totaamwin32:

oops (caught by the unit tests): r23233


Sat, 23 Jan 2021 05:44:17 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2178