Add Apps.AppListSearchQueryLength UMA histogram.
[chromium-blink-merge.git] / build / android / pylib / utils / time_profile.py
blob45da7ff3af7df607d2938cde9fa8ee2d9fa24e2c
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import logging
6 import time
9 class TimeProfile(object):
10 """Class for simple profiling of action, with logging of cost."""
12 def __init__(self, description):
13 self._starttime = None
14 self._description = description
15 self.Start()
17 def Start(self):
18 self._starttime = time.time()
20 def Stop(self):
21 """Stop profiling and dump a log."""
22 if self._starttime:
23 stoptime = time.time()
24 logging.info('%fsec to perform %s',
25 stoptime - self._starttime, self._description)
26 self._starttime = None