Skip to content

Commit 6df398d

Browse files
committed
Refine and extend synthetic benchmarks stressing CDATA, text and attribute value processing.
1 parent faffff8 commit 6df398d

File tree

8 files changed

+7111
-38634
lines changed

8 files changed

+7111
-38634
lines changed

benches/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
cdata.xml -text
2+
text.xml -text
3+
attributes.xml -text

benches/attributes.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import string
2+
import random
3+
4+
letters = [letter for letter in string.ascii_letters]
5+
spaces = ["\t", "\r\n", "\n"]
6+
codes = [""", "&", "'", ">", "	", "
", "
"]
7+
refs = [f"&entity{idx};" for idx in range(5)]
8+
chunks = 5 * letters + spaces + codes
9+
chunks_with_refs = chunks + refs
10+
11+
with open("attributes.xml", "w") as file:
12+
file.write("<!DOCTYPE test [\n")
13+
14+
for idx in range(5):
15+
file.write(f"<!ENTITY entity{idx} '")
16+
17+
for _ in range(200):
18+
file.write(random.choice(chunks))
19+
20+
file.write("'>")
21+
22+
file.write("]>\n\n")
23+
24+
file.write("<root>\n")
25+
26+
for _ in range(1_000):
27+
file.write('\t<elem attr="')
28+
29+
for _ in range(200):
30+
file.write(random.choice(chunks_with_refs))
31+
32+
file.write('"/>\n')
33+
34+
file.write("</root>\n")

benches/attributes.xml

Lines changed: 2494 additions & 0 deletions
Large diffs are not rendered by default.

benches/cdata.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import string
2+
import random
3+
4+
letters = [letter for letter in string.ascii_letters]
5+
lines = ["\r\n", "\n"]
6+
chunks = letters + lines
7+
8+
with open("cdata.xml", "w") as file:
9+
file.write("<root><![CDATA[")
10+
11+
for _ in range(100_000):
12+
file.write(random.choice(chunks))
13+
14+
file.write("]]></root>")

0 commit comments

Comments
 (0)