| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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. | 
|  | 4 | 
|  | 5 import logging | 
|  | 6 import time | 
|  | 7 | 
|  | 8 | 
|  | 9 class TimeProfile(object): | 
|  | 10   """Class for simple profiling of action, with logging of cost.""" | 
|  | 11 | 
|  | 12   def __init__(self, description): | 
|  | 13     self._starttime = None | 
|  | 14     self._description = description | 
|  | 15     self.Start() | 
|  | 16 | 
|  | 17   def Start(self): | 
|  | 18     self._starttime = time.time() | 
|  | 19 | 
|  | 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 | 
| OLD | NEW | 
|---|