File: test_timers.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (22 lines) | stat: -rwxr-xr-x 354 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import signal
import time


start = -1
loop = 10
def callback(*args):
    global loop
    global start
    print(time.perf_counter() - start)
    start = time.perf_counter()
    loop -= 1

signal.signal(signal.SIGALRM, callback)

start = time.perf_counter()
signal.setitimer(signal.ITIMER_REAL, 5, 1)

i = 0
while loop > 0:
    i += 1
    time.sleep(0.1)