OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # |
| 3 # Copyright 2016 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 |
| 9 import datetime |
| 10 |
| 11 |
| 12 class print_timings(object): |
| 13 def __init__(self): |
| 14 self._start = None |
| 15 |
| 16 def __enter__(self): |
| 17 self._start = datetime.datetime.utcnow() |
| 18 print 'Task started at %s GMT' % str(self._start) |
| 19 |
| 20 def __exit__(self, t, v, tb): |
| 21 finish = datetime.datetime.utcnow() |
| 22 duration = (finish-self._start).total_seconds() |
| 23 print 'Task finished at %s GMT (%f seconds)' % (str(finish), duration) |
OLD | NEW |