about summary refs log tree commit diff
path: root/gn2/maintenance/print_benchmark.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/maintenance/print_benchmark.py')
-rw-r--r--gn2/maintenance/print_benchmark.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/gn2/maintenance/print_benchmark.py b/gn2/maintenance/print_benchmark.py
new file mode 100644
index 00000000..9d12da8a
--- /dev/null
+++ b/gn2/maintenance/print_benchmark.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+import time
+
+from pprint import pformat as pf
+
+
+class TheCounter:
+    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()