Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_clock(self):
yappi.set_clock_type('cpu')
self.assertEqual('cpu', yappi.get_clock_type())
clock_info = yappi.get_clock_info()
self.assertTrue('api' in clock_info)
self.assertTrue('resolution' in clock_info)
yappi.set_clock_type('wall')
self.assertEqual('wall', yappi.get_clock_type())
t0 = yappi.get_clock_time()
time.sleep(0.1)
duration = yappi.get_clock_time() - t0
self.assertTrue(0.05 < duration < 0.2)
def burn_cpu(sec):
t0 = yappi.get_clock_time()
elapsed = 0
while (elapsed < sec):
for _ in range(1000):
pass
elapsed = yappi.get_clock_time() - t0
def test_get_clock(self):
yappi.set_clock_type('cpu')
self.assertEqual('cpu', yappi.get_clock_type())
clock_info = yappi.get_clock_info()
self.assertTrue('api' in clock_info)
self.assertTrue('resolution' in clock_info)
yappi.set_clock_type('wall')
self.assertEqual('wall', yappi.get_clock_type())
t0 = yappi.get_clock_time()
time.sleep(0.1)
duration = yappi.get_clock_time() - t0
self.assertTrue(0.05 < duration < 0.2)
def burn_cpu(sec):
t0 = yappi.get_clock_time()
elapsed = 0
while (elapsed < sec):
for _ in range(1000):
pass
elapsed = yappi.get_clock_time() - t0