本文整理汇总了Python中mozsystemmonitor.resourcemonitor.SystemResourceMonitor.between_events_usage方法的典型用法代码示例。如果您正苦于以下问题:Python SystemResourceMonitor.between_events_usage方法的具体用法?Python SystemResourceMonitor.between_events_usage怎么用?Python SystemResourceMonitor.between_events_usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozsystemmonitor.resourcemonitor.SystemResourceMonitor
的用法示例。
在下文中一共展示了SystemResourceMonitor.between_events_usage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_events
# 需要导入模块: from mozsystemmonitor.resourcemonitor import SystemResourceMonitor [as 别名]
# 或者: from mozsystemmonitor.resourcemonitor.SystemResourceMonitor import between_events_usage [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)