blob: cce0b05c20f189e568fa23cd7b1c3c09852dd1f3 [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Tools for recording and reporting timeline of benchmark_run."""
from __future__ import print_function
__author__ = ' (Yunlian Jiang)'
import time
class Event(object):
"""One event on the timeline."""
def __init__(self, name='', cur_time=0): = name
self.timestamp = cur_time
class Timeline(object):
"""Use a dict to store the timeline."""
def __init__(self): = []
def Record(self, event):
for e in
assert != event, (
'The event {0} is already recorded.'.format(event))
cur_event = Event(name=event, cur_time=time.time())
def GetEvents(self):
return ([ for e in])
def GetEventDict(self):
tl = {}
for e in
tl[] = e.timestamp
return tl
def GetEventTime(self, event):
for e in
if == event:
return e.timestamp
raise IndexError('The event {0} is not recorded'.format(event))
def GetLastEventTime(self):
def GetLastEvent(self):