aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/benchmark.py
diff options
context:
space:
mode:
authorArthur Centeno2021-10-25 21:04:23 +0000
committerArthur Centeno2021-10-25 21:04:23 +0000
commit499a80f138030c4de1629c043c8f9401a99894ea (patch)
tree449dcae965d13f966fb6d52625fbc86661c8c6a0 /wqflask/utility/benchmark.py
parent6151faa9ea67af4bf4ea95fb681a9dc4319474b6 (diff)
parent700802303e5e8221a9d591ba985d6607aa61e1ce (diff)
downloadgenenetwork2-499a80f138030c4de1629c043c8f9401a99894ea.tar.gz
Merge github.com:genenetwork/genenetwork2 into acenteno
Diffstat (limited to 'wqflask/utility/benchmark.py')
-rw-r--r--wqflask/utility/benchmark.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index 8f1c916b..6ece2f21 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -1,14 +1,13 @@
-from __future__ import print_function, division, absolute_import
-
import collections
import inspect
import time
from utility.tools import LOG_BENCH
from utility.logger import getLogger
-logger = getLogger(__name__ )
+logger = getLogger(__name__)
+
-class Bench(object):
+class Bench:
entries = collections.OrderedDict()
def __init__(self, name=None, write_output=LOG_BENCH):
@@ -20,7 +19,8 @@ class Bench(object):
if self.name:
logger.debug("Starting benchmark: %s" % (self.name))
else:
- logger.debug("Starting benchmark at: %s [%i]" % (inspect.stack()[1][3], inspect.stack()[1][2]))
+ logger.debug("Starting benchmark at: %s [%i]" % (
+ inspect.stack()[1][3], inspect.stack()[1][2]))
self.start_time = time.time()
def __exit__(self, type, value, traceback):
@@ -34,14 +34,16 @@ class Bench(object):
logger.info(" %s took: %f seconds" % (name, (time_taken)))
if self.name:
- Bench.entries[self.name] = Bench.entries.get(self.name, 0) + time_taken
+ Bench.entries[self.name] = Bench.entries.get(
+ self.name, 0) + time_taken
@classmethod
def report(cls):
- total_time = sum((time_taken for time_taken in cls.entries.itervalues()))
+ total_time = sum(
+ (time_taken for time_taken in list(cls.entries.values())))
print("\nTiming report\n")
- for name, time_taken in cls.entries.iteritems():
- percent = int(round((time_taken/total_time) * 100))
+ for name, time_taken in list(cls.entries.items()):
+ percent = int(round((time_taken / total_time) * 100))
print("[{}%] {}: {}".format(percent, name, time_taken))
print()