13996: Copy config into OrderedOptions for nicer access
[arvados.git] / services / fuse / tests / prof.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 import time
6
7 class CountTime(object):
8     def __init__(self, tag="", size=None):
9         self.tag = tag
10         self.size = size
11
12     def __enter__(self):
13         self.start = time.time()
14         return self
15
16     def __exit__(self, exc_type, exc_value, traceback):
17         sec = (time.time() - self.start)
18         th = ""
19         if self.size:
20             th = "throughput %s/sec" % (self.size / sec)
21         print "%s time %s micoseconds %s" % (self.tag, sec*1000000, th)