MCPcopy Index your code
hub / github.com/RustPython/RustPython / measure_itimer_resolution

Method measure_itimer_resolution

Lib/test/test_signal.py:1229–1251  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1227 self.addCleanup(signal.signal, signum, old_handler)
1228
1229 def measure_itimer_resolution(self):
1230 N = 20
1231 times = []
1232
1233 def handler(signum=None, frame=None):
1234 if len(times) < N:
1235 times.append(time.perf_counter())
1236 # 1 µs is the smallest possible timer interval,
1237 # we want to measure what the concrete duration
1238 # will be on this platform
1239 signal.setitimer(signal.ITIMER_REAL, 1e-6)
1240
1241 self.addCleanup(signal.setitimer, signal.ITIMER_REAL, 0)
1242 self.setsig(signal.SIGALRM, handler)
1243 handler()
1244 while len(times) < N:
1245 time.sleep(1e-3)
1246
1247 durations = [times[i+1] - times[i] for i in range(len(times) - 1)]
1248 med = statistics.median(durations)
1249 if support.verbose:
1250 print("detected median itimer() resolution: %.6f s." % (med,))
1251 return med
1252
1253 def decide_itimer_count(self):
1254 # Some systems have poor setitimer() resolution (for example

Callers 1

decide_itimer_countMethod · 0.95

Calls 7

setsigMethod · 0.95
handlerFunction · 0.85
lenFunction · 0.85
addCleanupMethod · 0.80
medianMethod · 0.80
printFunction · 0.50
sleepMethod · 0.45

Tested by

no test coverage detected