MCPcopy Create free account
hub / github.com/numpy/numpy / jiffies

Function jiffies

numpy/testing/_private/utils.py:149–165  ·  view source on GitHub ↗

Return number of jiffies elapsed. Return number of jiffies (1/100ths of a second) that this process has been scheduled in user mode. See man 5 proc.

(_proc_pid_stat=f'/proc/{os.getpid()}/stat', _load_time=[])

Source from the content-addressed store, hash-verified

147
148if sys.platform[:5] == 'linux':
149 def jiffies(_proc_pid_stat=f'/proc/{os.getpid()}/stat', _load_time=[]):
150 """
151 Return number of jiffies elapsed.
152
153 Return number of jiffies (1/100ths of a second) that this
154 process has been scheduled in user mode. See man 5 proc.
155
156 """
157 import time
158 if not _load_time:
159 _load_time.append(time.time())
160 try:
161 with open(_proc_pid_stat) as f:
162 l = f.readline().split(' ')
163 return int(l[13])
164 except Exception:
165 return int(100*(time.time()-_load_time[0]))
166else:
167 # os.getpid is not in all platforms available.
168 # Using time is safe but inaccurate, especially when process

Callers 1

measureFunction · 0.85

Calls 2

openFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected