Skip to content

Commit 09ea901

Browse files
committed
tests/extmod: Add test to compare time_ns with time.
They should be close together. Signed-off-by: Damien George <damien@micropython.org>
1 parent 1ec0c9b commit 09ea901

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/extmod/time_time_ns.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@
2222
print(True)
2323
else:
2424
print(t0, t1, t1 - t0)
25+
26+
# Check that time.time() and time.time_ns() are within a second of each other.
27+
# Note that time.time() may return an int or float.
28+
for _ in range(10):
29+
t_s, t_ns = time.time(), time.time_ns()
30+
print(abs(t_s * 1_000 - t_ns // 1_000_000) <= 1_000)
31+
time.sleep_us(100_000)

tests/extmod/time_time_ns.py.exp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
True
22
True
3+
True
4+
True
5+
True
6+
True
7+
True
8+
True
9+
True
10+
True
11+
True
12+
True

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy