diff options
Diffstat (limited to 'infra/bots/utils.py')
-rw-r--r-- | infra/bots/utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/infra/bots/utils.py b/infra/bots/utils.py new file mode 100644 index 0000000000..ee648a26a4 --- /dev/null +++ b/infra/bots/utils.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +import datetime + + +class print_timings(object): + def __init__(self): + self._start = None + + def __enter__(self): + self._start = datetime.datetime.utcnow() + print 'Task started at %s GMT' % str(self._start) + + def __exit__(self, t, v, tb): + finish = datetime.datetime.utcnow() + duration = (finish-self._start).total_seconds() + print 'Task finished at %s GMT (%f seconds)' % (str(finish), duration) |