Merge branch 'use_mktemp' of https://github.com/golharam/arvados into golharam-use_mktemp
[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 from __future__ import print_function
6 from builtins import object
7 import time
8
9 class CountTime(object):
10     def __init__(self, tag="", size=None):
11         self.tag = tag
12         self.size = size
13
14     def __enter__(self):
15         self.start = time.time()
16         return self
17
18     def __exit__(self, exc_type, exc_value, traceback):
19         sec = (time.time() - self.start)
20         th = ""
21         if self.size:
22             th = "throughput %s/sec" % (self.size // sec)
23         print("%s time %s micoseconds %s" % (self.tag, sec*1000000, th))