11789: Converting a filter() iterable to list, for python3 compatibility.
[arvados.git] / sdk / python / arvados / timer.py
1 from __future__ import print_function
2 from builtins import object
3 import time
4
5 class Timer(object):
6     def __init__(self, verbose=False):
7         self.verbose = verbose
8
9     def __enter__(self):
10         self.start = time.time()
11         return self
12
13     def __exit__(self, *args):
14         self.end = time.time()
15         self.secs = self.end - self.start
16         self.msecs = self.secs * 1000  # millisecs
17         if self.verbose:
18             print('elapsed time: %f ms' % self.msecs)