Skip to content

Commit fafa4b7

Browse files
committed
do not sample past deadline
1 parent de0d2aa commit fafa4b7

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Tools/inspection/oracle_external_inspection.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,21 @@ def run_mode(case, mode_name, args):
159159
rate_hz = args.rate_khz * 1000
160160
period = 1.0 / rate_hz if rate_hz else 0
161161
next_sample = time.perf_counter()
162-
deadline = time.perf_counter() + args.duration
162+
deadline = next_sample + args.duration
163163

164164
while time.perf_counter() < deadline:
165-
result["attempts"] += 1
166165
if period:
167166
if args.poisson_sampling:
168-
time.sleep(random.expovariate(rate_hz))
169-
else:
170-
now = time.perf_counter()
171-
if next_sample > now:
172-
time.sleep(next_sample - now)
167+
next_sample += random.expovariate(rate_hz)
168+
if next_sample >= deadline:
169+
break
170+
now = time.perf_counter()
171+
if next_sample > now:
172+
time.sleep(next_sample - now)
173+
if not args.poisson_sampling:
173174
next_sample += period
174175

176+
result["attempts"] += 1
175177
work_start = time.perf_counter()
176178
try:
177179
trace = get_trace(unwinder, blocking, op)

0 commit comments

Comments
 (0)