-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_out.py
49 lines (35 loc) · 1.19 KB
/
time_out.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
# early attempt at profiling this
#~ python3 -m timeit -n 10000 "$(cat time_out.py)"
#~ 10000 loops, best of 5: 25.4 usec per loop
import out
#~ basic = True
basic = False
try:
if basic:
import cProfile
with cProfile.Profile() as pr:
for _ in range(10_000):
out.trace('debug: {"text": "from main"}')
out.debug('debug: {"text": "from main"}')
out.info('info text')
out.note('note text')
out.warn('warn text')
out.fatal('fatal text')
pr.print_stats(sort='cumulative')
else:
out.configure(lexer='json')
import cProfile
with cProfile.Profile() as pr:
for _ in range(10_000):
out.debug(
'debug message: JSON: %s',
'{"data": [null, true, false, "hi", 123]}'
)
out.warn('warn: {"text": "from main"}')
out.error(
'error message: JSON: %s',
'{"data": [null, true, false, "hi", 123]}'
)
pr.print_stats(sort='cumulative')
except BrokenPipeError as err:
err