本文整理汇总了Python中mozsystemmonitor.resourcemonitor.SystemResourceMonitor.record_event方法的典型用法代码示例。如果您正苦于以下问题:Python SystemResourceMonitor.record_event方法的具体用法?Python SystemResourceMonitor.record_event怎么用?Python SystemResourceMonitor.record_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozsystemmonitor.resourcemonitor.SystemResourceMonitor
的用法示例。
在下文中一共展示了SystemResourceMonitor.record_event方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_events
# 需要导入模块: from mozsystemmonitor.resourcemonitor import SystemResourceMonitor [as 别名]
# 或者: from mozsystemmonitor.resourcemonitor.SystemResourceMonitor import record_event [as 别名]
def test_events(self):
monitor = SystemResourceMonitor(poll_interval=0.25)
monitor.start()
time.sleep(0.5)
t0 = time.time()
monitor.record_event('t0')
time.sleep(0.5)
t1 = time.time()
monitor.record_event('t1')
time.sleep(0.5)
monitor.stop()
events = monitor.events
self.assertEqual(len(events), 2)
event = events[0]
self.assertEqual(event[1], 't0')
self.assertAlmostEqual(event[0], t0, delta=0.25)
data = list(monitor.between_events_usage('t0', 't1'))
self.assertGreater(len(data), 0)
示例2: test_as_dict
# 需要导入模块: from mozsystemmonitor.resourcemonitor import SystemResourceMonitor [as 别名]
# 或者: from mozsystemmonitor.resourcemonitor.SystemResourceMonitor import record_event [as 别名]
def test_as_dict(self):
monitor = SystemResourceMonitor(poll_interval=0.25)
monitor.start()
time.sleep(0.1)
monitor.begin_phase('phase1')
monitor.record_event('foo')
time.sleep(0.1)
monitor.begin_phase('phase2')
monitor.record_event('bar')
time.sleep(0.2)
monitor.finish_phase('phase1')
time.sleep(0.2)
monitor.finish_phase('phase2')
time.sleep(0.4)
monitor.stop()
d = monitor.as_dict()
self.assertEqual(d['version'], 2)
self.assertEqual(len(d['events']), 2)
self.assertEqual(len(d['phases']), 2)
self.assertIn('system', d)
self.assertIsInstance(d['system'], dict)
self.assertIsInstance(d['overall'], dict)
self.assertIn('duration', d['overall'])
self.assertIn('cpu_times', d['overall'])
示例3: test_as_dict
# 需要导入模块: from mozsystemmonitor.resourcemonitor import SystemResourceMonitor [as 别名]
# 或者: from mozsystemmonitor.resourcemonitor.SystemResourceMonitor import record_event [as 别名]
def test_as_dict(self):
monitor = SystemResourceMonitor(poll_interval=0.25)
monitor.start()
time.sleep(0.1)
monitor.begin_phase('phase1')
monitor.record_event('foo')
time.sleep(0.1)
monitor.begin_phase('phase2')
monitor.record_event('bar')
time.sleep(0.2)
monitor.finish_phase('phase1')
time.sleep(0.2)
monitor.finish_phase('phase2')
time.sleep(0.4)
monitor.stop()
d = monitor.as_dict()
self.assertEqual(d['version'], 1)
self.assertEqual(len(d['events']), 2)
self.assertEqual(len(d['phases']), 2)