xpra icon
Bug tracker and wiki

Opened 18 months ago

Closed 14 months ago

Last modified 13 months ago

#2178 closed task (fixed)

better monotonic clock for win32

Reported by: Antoine Martin Owned by: totaamwin32
Priority: major Milestone: 3.0
Component: platforms Version: 2.4.x
Keywords: Cc: stdedos@…

Description

Using QueryUnbiasedInterruptTime which requires windows 10, or QueryPerformanceCounter (windows 2000 and later).

Change History (4)

comment:1 Changed 18 months ago by stdedos

Cc: stdedos@… added

comment:2 Changed 14 months ago by totaamwin32

Owner: changed from Antoine Martin to totaamwin32
Status: newassigned

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

comment:3 Changed 14 months ago by totaamwin32

Resolution: fixed
Status: assignedclosed

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.

Last edited 14 months ago by Antoine Martin (previous) (diff)

comment:4 Changed 13 months ago by totaamwin32

oops (caught by the unit tests): r23233

Note: See TracTickets for help on using tickets.