aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/benchmark.py
diff options
context:
space:
mode:
authorzsloan2021-04-30 18:40:13 +0000
committerzsloan2021-04-30 18:40:13 +0000
commit21b2e2a552b8b6bedb789263543a4d6d039ac8a9 (patch)
treefe55511b99a522198c1b840909d7b91c9b45ab22 /wqflask/utility/benchmark.py
parent699b952c7bda5426f3f3e947454f656a4ec7538b (diff)
parent799b25481fffc97e2adb07004adf502096bf371c (diff)
downloadgenenetwork2-21b2e2a552b8b6bedb789263543a4d6d039ac8a9.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into testing
Diffstat (limited to 'wqflask/utility/benchmark.py')
-rw-r--r--wqflask/utility/benchmark.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index 91ea91e8..6ece2f21 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -4,7 +4,8 @@ import time
from utility.tools import LOG_BENCH
from utility.logger import getLogger
-logger = getLogger(__name__ )
+logger = getLogger(__name__)
+
class Bench:
entries = collections.OrderedDict()
@@ -18,7 +19,8 @@ class Bench:
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:
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()