-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.py
46 lines (34 loc) · 1.9 KB
/
benchmark.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
import json
import functime
from tp_html import *
def test():
template = Template(template_file='samples/basic_template.min.html')
# template.save_template('samples/basic_template.min.html')
parser = ThtmlParser(template=template)
data = parser.parse(page_file=r'samples/basic_sample.html')
print(json.dumps(data, ensure_ascii=False))
template = Template(template_file='samples/complex_template.html')
# template.save_template('samples/basic_template.min.html')
parser = ThtmlParser(template=template)
data = parser.parse(page_file=r'samples/complex_sample.html')
print(json.dumps(data, ensure_ascii=False))
template = Template(template_file='samples/pixiv_user_template.html')
# template.save_template('samples/basic_template.min.html')
parser = ThtmlParser(template=template)
data = parser.parse(page_file=r'samples/pixiv_user.html')
print(json.dumps(data, ensure_ascii=False))
def benchmark():
parser = ThtmlParser(template_file='samples/basic_template.html')
functime.func_time(Template, template_file='samples/basic_template.html')
functime.func_time(parser.parse, page_file=r'samples/basic_sample.html')
parser = ThtmlParser(template_file='samples/complex_template.html')
functime.func_time(Template, template_file='samples/complex_template.html')
functime.func_time(parser.parse, page_file=r'samples/complex_sample.html')
parser = ThtmlParser(template_file='samples/pixiv_user_template.html')
functime.func_time(Template, template_file='samples/pixiv_user_template.html')
functime.func_time(parser.parse, page_file=r'samples/pixiv_user.html')
parser = ThtmlParser(template_file='samples/pixiv_user_template.min.html')
functime.func_time(Template, template_file='samples/pixiv_user_template.min.html')
functime.func_time(parser.parse, page_file=r'samples/pixiv_user.html')
if __name__ == '__main__':
benchmark()