1- import sys
2- import threading
31import time
42
53from distributed import metrics
6- from distributed .utils_test import run_for
74
85
96def test_wall_clock ():
@@ -18,46 +15,3 @@ def test_wall_clock():
1815 assert any (lambda d : 0.0 < d < 0.0001 for d in deltas ), deltas
1916 # Close to time.time()
2017 assert t - 0.5 < samples [0 ] < t + 0.5
21-
22-
23- def test_process_time ():
24- start = metrics .process_time ()
25- run_for (0.05 )
26- dt = metrics .process_time () - start
27- assert 0.03 <= dt <= 0.2
28-
29- # All threads counted
30- t = threading .Thread (target = run_for , args = (0.1 ,))
31- start = metrics .process_time ()
32- t .start ()
33- t .join ()
34- dt = metrics .process_time () - start
35- assert dt >= 0.05
36-
37- # Sleep time not counted
38- start = metrics .process_time ()
39- time .sleep (0.1 )
40- dt = metrics .process_time () - start
41- assert dt <= 0.05
42-
43-
44- def test_thread_time ():
45- start = metrics .thread_time ()
46- run_for (0.05 )
47- dt = metrics .thread_time () - start
48- assert 0.03 <= dt <= 0.2
49-
50- # Sleep time not counted
51- start = metrics .thread_time ()
52- time .sleep (0.1 )
53- dt = metrics .thread_time () - start
54- assert dt <= 0.05
55-
56- if sys .platform == "linux" :
57- # Always per-thread on Linux
58- t = threading .Thread (target = run_for , args = (0.1 ,))
59- start = metrics .thread_time ()
60- t .start ()
61- t .join ()
62- dt = metrics .thread_time () - start
63- assert dt <= 0.05
0 commit comments