aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/benchmark.py
diff options
context:
space:
mode:
authorArthur Centeno2021-06-15 15:33:59 +0000
committerArthur Centeno2021-06-15 15:33:59 +0000
commitc1a6ca69f7c48d99b6c5d62e56a445583fd4c08b (patch)
treef98fccc44829e3f52e585d6b41a1942aa52bd8b7 /wqflask/utility/benchmark.py
parent7e49c006af9c4f7453c3578a7d4f1fc4d7bdf3ed (diff)
parent9e9e0e4d440383f617542e810a1115833eafd7bf (diff)
downloadgenenetwork2-c1a6ca69f7c48d99b6c5d62e56a445583fd4c08b.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into acenteno
Diffstat (limited to 'wqflask/utility/benchmark.py')
-rw-r--r--wqflask/utility/benchmark.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index ea5a0ab6..6ece2f21 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -4,9 +4,10 @@ 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):
@@ -18,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):
@@ -32,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 list(cls.entries.values())))
+ total_time = sum(
+ (time_taken for time_taken in list(cls.entries.values())))
print("\nTiming report\n")
for name, time_taken in list(cls.entries.items()):
- percent = int(round((time_taken/total_time) * 100))
+ percent = int(round((time_taken / total_time) * 100))
print("[{}%] {}: {}".format(percent, name, time_taken))
print()