Reported resolution of `time.process_time` and `time.thread_time` is wrong on Windows
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
>>> import time
>>> time.get_clock_info("process_time")
namespace(implementation='GetProcessTimes()', monotonic=True, adjustable=False, resolution=1e-07)
>>> time.get_clock_info("thread_time")
namespace(implementation='GetThreadTimes()', monotonic=True, adjustable=False, resolution=1e-07)
The reported resolution=1e-07 is way off. According to @eryksun in https://github.com/python/cpython/issues/82040#issuecomment-1093831784
Don't read too much into the clock info here:
Process times [1] are stored as a 64-bit integer in units of 100 ns (1e-7). But the kernel schedules threads based on a timer that ticks every 15.625 ms by default. It can be lowered to about 0.5 ms, but this degrades battery life.
This has also caused problems in test_int.test_denial_of_service, see https://github.com/python/cpython/issues/114911#issuecomment-2567094984.
I suggest to report 15.625 ms, since this is the upper limit.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-135305
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Prüfung des verknüpften PR gh-135305 und des Verhaltens von time.get_clock_info("process_time") und time.get_clock_info("thread_time") unter Windows. Prüfe test_int.test_denial_of_service auf die damit verbundenen Auswirkungen; abgeschlossen ist die Aufgabe, wenn die gemeldeten Auflösungen das beabsichtigte Windows-Timingverhalten widerspiegeln und der betroffene Test erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100