-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspeedTest.py
93 lines (80 loc) · 2.45 KB
/
speedTest.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#==============================
# file: test.py
# info: Demonstration of how to use neatlog
#==============================
import neatlog
from neatlog import colorlog
import logging
import time
def test():
one()
def one():
two()
def two():
three()
def three():
four()
def four():
five()
def five():
six()
def six():
last()
def last():
# Create some logs from lowest to highest level
LOG.debug('debug {0}'.format("something"))
LOG.info('info')
LOG.warning('warning')
LOG.error('error')
LOG.critical('critical')
try:
1/0
except:
LOG.exception("lol")
if __name__ == '__main__':
samples = 3 # How many times to run over the iterations
iterations = 1000 # How many logs to create
# Logging
fm = logging.Formatter("%(levelname)s : %(filename)s :: %(asctime)s.%(msecs)d - %(funcName)s - %(lineno)d >> %(message)s","%H:%M:%S")
ch = logging.StreamHandler()
ch.setFormatter(fm)
LOG = logging.getLogger("logging")
LOG.addHandler(ch)
LOG.setLevel(logging.DEBUG)
lgFinalTime = 0
for i in range(0, samples):
lgStartTime = time.time()
for j in range(0, iterations):
LOG.debug('test')
lgFinalTime += time.time()-lgStartTime
lgFinalTime /= samples
# Colorlog
fm = colorlog.ColoredFormatter("%(log_color)s%(levelname)s : %(filename)s :: %(asctime)s.%(msecs)d - %(funcName)s - %(lineno)d >> %(message)s","%H:%M:%S")
ch = colorlog.StreamHandler()
ch.setFormatter(fm)
LOG = colorlog.getLogger("colorlog")
LOG.addHandler(ch)
LOG.setLevel(logging.DEBUG)
clFinalTime = 0
for i in range(0, samples):
clStartTime = time.time()
for j in range(0, iterations):
LOG.debug('test')
clFinalTime += time.time()-clStartTime
clFinalTime /= samples
# Neatlog
LOG = neatlog.getLogger("neatlog", color=False)
LOG.setLevel('debug')
LOG.setVerbosity(100)
nlFinalTime = 0
for i in range(0, samples):
nlStartTime = time.time()
for j in range(0, iterations):
LOG.debug('test')
nlFinalTime += time.time()-nlStartTime
nlFinalTime /= samples
test()
# RESULTS
print("'logging' logged %s logs in %s seconds on average"%(iterations, lgFinalTime))
print("'colorlog' logged %s logs in %s seconds on average"%(iterations, clFinalTime))
print("'neatlog' logged %s logs in %s seconds on average"%(iterations, nlFinalTime))