MCPcopy
hub / github.com/locustio/locust / test_constant_throughput

Method test_constant_throughput

locust/test/test_wait_time.py:59–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

57 self.assertLess(time.perf_counter() - start_time, 0.002)
58
59 def test_constant_throughput(self):
60 class MyUser(User):
61 wait_time = constant_throughput(10)
62
63 class TS(TaskSet):
64 pass
65
66 ts = TS(MyUser(self.environment))
67
68 ts2 = TS(MyUser(self.environment))
69
70 previous_time = time.perf_counter()
71 for i in range(7):
72 ts.wait()
73 since_last_run = time.perf_counter() - previous_time
74 self.assertLess(abs(0.1 - since_last_run), 0.02)
75 previous_time = time.perf_counter()
76 time.sleep(random.random() * 0.1)
77 _ = ts2.wait_time()
78 _ = ts2.wait_time()

Callers

nothing calls this directly

Calls 4

TSClass · 0.70
MyUserClass · 0.70
waitMethod · 0.45
wait_timeMethod · 0.45

Tested by

no test coverage detected