-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
46 lines (35 loc) · 1.05 KB
/
test.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
from xmlo3 import parse_file_roxmltree, parse_file_xmlparser
from time import perf_counter
from xml.parsers.expat import ParserCreate
from lxml import etree, sax
# # roxmltree
# start = perf_counter()
# parse_file_roxmltree("files/nasa.xml")
# print(f"roxmltree: {perf_counter()- start}")
# xml parser
start = perf_counter()
parse_file_xmlparser("files/nasa.xml")
print(f"xmlparser: {perf_counter()- start}")
# xpat
start = perf_counter()
parser = ParserCreate()
with open("files/nasa.xml") as file:
doc = file.read()
parser.Parse(doc)
print(f"expat: {perf_counter()- start}")
# # lxml
# start = perf_counter()
# tree = etree.parse("files/nasa.xml")
# print(f"lxml tree: {perf_counter()- start}")
# start = perf_counter()
# with open("files/nasa.xml") as file:
# parser = etree.XMLPullParser()
# doc = file.read()
# parser.feed(doc)
# parser.close()
# print(f"lxml pull: {perf_counter()- start}")
# # xml parser
# start = perf_counter()
# out = parse_file_xmlparser("files/note.xml")
# print(out)
# print(f"xmlparser: {perf_counter()- start}")