8000 time.sleep waits less than expected · Issue #9693 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
time.sleep waits less than expected #9693
Closed
@ishahak

Description

@ishahak

CircuitPython version

Adafruit CircuitPython 8.1.0-beta.1-48-g98a1083d6-dirty on 2023-08-22; ESP32-S3-DevKitC-1-N32R8 with ESP32S3

Code/REPL

import time

LOOP=200
acc = 0
for i in range(LOOP):
    t = time.monotonic_ns()
    time.sleep(0.01)
    t2 = time.monotonic_ns()
    diff_us = (t2-t) // 1000
    acc += diff_us
avg = acc / LOOP
print(f'expected 10000 us, got {avg} us')

Behavior

The result shows:
expected 10000 us, got 9799.07 us

Description

see:
https://forums.adafruit.com/viewtopic.php?p=1024856#p1024856

Additional information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0