Merge branch '14323-container-collection-mounts'
[arvados.git] / sdk / python / arvados / timer.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 from __future__ import print_function
6 from builtins import object
7 import time
8
9 class Timer(object):
10     def __init__(self, verbose=False):
11         self.verbose = verbose
12
13     def __enter__(self):
14         self.start = time.time()
15         return self
16
17     def __exit__(self, *args):
18         self.end = time.time()
19         self.secs = self.end - self.start
20         self.msecs = self.secs * 1000  # millisecs
21         if self.verbose:
22             print('elapsed time: %f ms' % self.msecs)