aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/print_benchmark.py
diff options
context:
space:
mode:
authorLei Yan2013-06-19 21:08:43 +0000
committerLei Yan2013-06-19 21:08:43 +0000
commit0dd5dfb3925b2198487480d6093eed0d92201fc6 (patch)
treecc103e4067d42442b0d86602f104a406d172945d /wqflask/maintenance/print_benchmark.py
parent71f1a5d52d58d07294ef3f2cfa87026025358e74 (diff)
parentaac1dd2f9c5b216b24c6e35676ba5d50f9d5d3c2 (diff)
downloadgenenetwork2-0dd5dfb3925b2198487480d6093eed0d92201fc6.tar.gz
Merge branch 'flask' of git://github.com/zsloan/genenetwork into flask
Conflicts: wqflask/base/data_set.py
Diffstat (limited to 'wqflask/maintenance/print_benchmark.py')
-rw-r--r--wqflask/maintenance/print_benchmark.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/wqflask/maintenance/print_benchmark.py b/wqflask/maintenance/print_benchmark.py
new file mode 100644
index 00000000..540e0904
--- /dev/null
+++ b/wqflask/maintenance/print_benchmark.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+from __future__ import absolute_import, print_function, division
+
+import time
+
+from pprint import pformat as pf
+
+
+class TheCounter(object):
+ Counters = {}
+
+ def __init__(self):
+ start_time = time.time()
+ for counter in range(170000):
+ self.print_it(counter)
+ self.time_took = time.time() - start_time
+ TheCounter.Counters[self.__class__.__name__] = self.time_took
+
+class PrintAll(TheCounter):
+ def print_it(self, counter):
+ print(counter)
+
+class PrintSome(TheCounter):
+ def print_it(self, counter):
+ if counter % 1000 == 0:
+ print(counter)
+
+class PrintNone(TheCounter):
+ def print_it(self, counter):
+ pass
+
+
+def new_main():
+ print("Running new_main")
+ tests = [PrintAll, PrintSome, PrintNone]
+ for test in tests:
+ test()
+
+ print(pf(TheCounter.Counters))
+
+if __name__ == '__main__':
+ new_main() \ No newline at end of file