blob: b24ce4f12818036e5f18be3cdb472ad3a11a779f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/python
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()
|