-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformance.py
executable file
·53 lines (39 loc) · 958 Bytes
/
performance.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
#!/usr/bin/env python
import markdown, timeit
# Don't add ^ markers in baseline test, as those would become extra attributes
sb = """
First do these steps:
1. Item
{ .myitem .mylist }
2. Item
{ #item2 #list1 }
3. Item
Don't forget to finish with these steps:
4. Item
{ start=4 .important }
5. Especially the last one!
{ style="font-style: bold" }
"""
spm = """
First do these steps:
1. Item
{ .myitem ^ .mylist }
2. Item
{ #item2 ^ #list1 }
3. Item
Don't forget to finish with these steps:
4. Item
{ ^ start=4 .important }
5. Especially the last one!
{ style="font-style: bold" }
"""
R = 100
def baseline():
markdown.markdown(sb*R, extensions=['attr_list'])
def pm():
markdown.markdown(spm*R, extensions=['pm_attr_list'])
N = 100
tb = timeit.timeit('baseline()', globals=globals(), number=N)
tbpm = timeit.timeit('pm()', globals=globals(), number=N)
print('%.3fs' % tb)
print('%.3fs (+%.1f%%)' % (tbpm, (tbpm-tb)/tb*100.0))