Skip to content

Commit efbe372

Browse files
committed
perf(support): cache parse_uri results and refactor URI helper functions
Add LRU cache to parse_uri() and refactor get_short_name(), get_count(), get_prefix(), get_base_iri(), get_resource_number() to use cached parse_uri() instead of _get_match() which compiled regex on every call. Benchmark improvement: ~1.6x speedup on find_paths operations.
1 parent 9dbd09e commit efbe372

File tree

3 files changed

+350
-33
lines changed

3 files changed

+350
-33
lines changed
Lines changed: 341 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
{
2+
"machine_info": {
3+
"node": "c5fc5c88d4f1",
4+
"processor": "",
5+
"machine": "x86_64",
6+
"python_compiler": "GCC 14.2.0",
7+
"python_implementation": "CPython",
8+
"python_implementation_version": "3.11.14",
9+
"python_version": "3.11.14",
10+
"python_build": [
11+
"main",
12+
"Nov 18 2025 05:57:35"
13+
],
14+
"release": "6.17.8-arch1-1",
15+
"system": "Linux",
16+
"cpu": {
17+
"python_version": "3.11.14.final.0 (64 bit)",
18+
"cpuinfo_version": [
19+
9,
20+
0,
21+
0
22+
],
23+
"cpuinfo_version_string": "9.0.0",
24+
"arch": "X86_64",
25+
"bits": 64,
26+
"count": 24,
27+
"arch_string_raw": "x86_64",
28+
"vendor_id_raw": "GenuineIntel",
29+
"brand_raw": "12th Gen Intel(R) Core(TM) i9-12900K",
30+
"hz_advertised_friendly": "800.0000 MHz",
31+
"hz_actual_friendly": "800.0000 MHz",
32+
"hz_advertised": [
33+
800000000,
34+
0
35+
],
36+
"hz_actual": [
37+
800000000,
38+
0
39+
],
40+
"stepping": 2,
41+
"model": 151,
42+
"family": 6,
43+
"flags": [
44+
"3dnowprefetch",
45+
"abm",
46+
"acpi",
47+
"adx",
48+
"aes",
49+
"aperfmperf",
50+
"apic",
51+
"arat",
52+
"arch_capabilities",
53+
"arch_lbr",
54+
"arch_perfmon",
55+
"art",
56+
"avx",
57+
"avx2",
58+
"avx_vnni",
59+
"bmi1",
60+
"bmi2",
61+
"bts",
62+
"clflush",
63+
"clflushopt",
64+
"clwb",
65+
"cmov",
66+
"constant_tsc",
67+
"cpuid",
68+
"cpuid_fault",
69+
"cx16",
70+
"cx8",
71+
"de",
72+
"ds_cpl",
73+
"dtes64",
74+
"dtherm",
75+
"dts",
76+
"epb",
77+
"ept",
78+
"ept_ad",
79+
"erms",
80+
"est",
81+
"f16c",
82+
"flexpriority",
83+
"flush_l1d",
84+
"fma",
85+
"fpu",
86+
"fsgsbase",
87+
"fsrm",
88+
"fxsr",
89+
"gfni",
90+
"hfi",
91+
"ht",
92+
"hwp",
93+
"hwp_act_window",
94+
"hwp_epp",
95+
"hwp_notify",
96+
"hwp_pkg_req",
97+
"ibpb",
98+
"ibrs",
99+
"ibrs_enhanced",
100+
"ibt",
101+
"ida",
102+
"intel_pt",
103+
"invpcid",
104+
"lahf_lm",
105+
"lm",
106+
"mca",
107+
"mce",
108+
"md_clear",
109+
"mmx",
110+
"monitor",
111+
"movbe",
112+
"movdir64b",
113+
"movdiri",
114+
"msr",
115+
"mtrr",
116+
"nonstop_tsc",
117+
"nopl",
118+
"nx",
119+
"ospke",
120+
"osxsave",
121+
"pae",
122+
"pat",
123+
"pbe",
124+
"pcid",
125+
"pclmulqdq",
126+
"pconfig",
127+
"pdcm",
128+
"pdpe1gb",
129+
"pebs",
130+
"pge",
131+
"pku",
132+
"pln",
133+
"pni",
134+
"popcnt",
135+
"pse",
136+
"pse36",
137+
"pts",
138+
"rdpid",
139+
"rdrand",
140+
"rdrnd",
141+
"rdseed",
142+
"rdtscp",
143+
"rep_good",
144+
"sdbg",
145+
"sep",
146+
"serialize",
147+
"sha",
148+
"sha_ni",
149+
"smap",
150+
"smep",
151+
"smx",
152+
"split_lock_detect",
153+
"ss",
154+
"ssbd",
155+
"sse",
156+
"sse2",
157+
"sse4_1",
158+
"sse4_2",
159+
"ssse3",
160+
"stibp",
161+
"syscall",
162+
"tm",
163+
"tm2",
164+
"tpr_shadow",
165+
"tsc",
166+
"tsc_adjust",
167+
"tsc_deadline_timer",
168+
"tsc_known_freq",
169+
"tscdeadline",
170+
"umip",
171+
"user_shstk",
172+
"vaes",
173+
"vme",
174+
"vmx",
175+
"vnmi",
176+
"vpclmulqdq",
177+
"vpid",
178+
"waitpkg",
179+
"x2apic",
180+
"xgetbv1",
181+
"xsave",
182+
"xsavec",
183+
"xsaveopt",
184+
"xsaves",
185+
"xtopology",
186+
"xtpr"
187+
],
188+
"l3_cache_size": 31457280,
189+
"l2_cache_size": 14680064,
190+
"l1_data_cache_size": 655360,
191+
"l1_instruction_cache_size": 786432,
192+
"l2_cache_line_size": 1280,
193+
"l2_cache_associativity": 7
194+
}
195+
},
196+
"commit_info": {
197+
"id": "unknown",
198+
"time": null,
199+
"author_time": null,
200+
"dirty": false,
201+
"error": "CalledProcessError(128, \"fatal: detected dubious ownership in repository at '/app'\\nTo add an exception for this directory, call:\\n\\n\\tgit config --global --add safe.directory /app\\n\")",
202+
"project": "app",
203+
"branch": "(unknown)"
204+
},
205+
"benchmarks": [
206+
{
207+
"group": "find_paths",
208+
"name": "test_find_paths[100]",
209+
"fullname": "benchmarks/test_find_paths.py::TestFindPaths::test_find_paths[100]",
210+
"params": {
211+
"uri_count": 100
212+
},
213+
"param": "100",
214+
"extra_info": {},
215+
"options": {
216+
"disable_gc": false,
217+
"timer": "perf_counter",
218+
"min_rounds": 5,
219+
"max_time": 1.0,
220+
"min_time": 5e-06,
221+
"warmup": 1
222+
},
223+
"stats": {
224+
"min": 0.00017675300114206038,
225+
"max": 0.0004923229971609544,
226+
"mean": 0.00024313860049005598,
227+
"stddev": 0.00013936141114553473,
228+
"rounds": 5,
229+
"median": 0.00018263600213686004,
230+
"iqr": 8.622224959253799e-05,
231+
"q1": 0.00017701625074550975,
232+
"q3": 0.00026323850033804774,
233+
"iqr_outliers": 1,
234+
"stddev_outliers": 1,
235+
"outliers": "1;1",
236+
"ld15iqr": 0.00017675300114206038,
237+
"hd15iqr": 0.0004923229971609544,
238+
"ops": 4112.880464000608,
239+
"total": 0.0012156930024502799,
240+
"data": [
241+
0.0004923229971609544,
242+
0.00018263600213686004,
243+
0.0001771040006133262,
244+
0.00017675300114206038,
245+
0.00018687700139707886
246+
],
247+
"iterations": 1
248+
}
249+
},
250+
{
251+
"group": "find_paths",
252+
"name": "test_find_paths[500]",
253+
"fullname": "benchmarks/test_find_paths.py::TestFindPaths::test_find_paths[500]",
254+
"params": {
255+
"uri_count": 500
256+
},
257+
"param": "500",
258+
"extra_info": {},
259+
"options": {
260+
"disable_gc": false,
261+
"timer": "perf_counter",
262+
"min_rounds": 5,
263+
"max_time": 1.0,
264+
"min_time": 5e-06,
265+
"warmup": 1
266+
},
267+
"stats": {
268+
"min": 0.000903104999451898,
269+
"max": 0.0025441530015086755,
270+
"mean": 0.001256698599900119,
271+
"stddev": 0.0007212093098825438,
272+
"rounds": 5,
273+
"median": 0.0009161730013147462,
274+
"iqr": 0.0004925789990011253,
275+
"q1": 0.0009046409995789872,
276+
"q3": 0.0013972199985801126,
277+
"iqr_outliers": 1,
278+
"stddev_outliers": 1,
279+
"outliers": "1;1",
280+
"ld15iqr": 0.000903104999451898,
281+
"hd15iqr": 0.0025441530015086755,
282+
"ops": 795.7357476800554,
283+
"total": 0.006283492999500595,
284+
"data": [
285+
0.0025441530015086755,
286+
0.001014908997603925,
287+
0.0009161730013147462,
288+
0.000903104999451898,
289+
0.0009051529996213503
290+
],
291+
"iterations": 1
292+
}
293+
},
294+
{
295+
"group": "find_paths",
296+
"name": "test_find_paths[1000]",
297+
"fullname": "benchmarks/test_find_paths.py::TestFindPaths::test_find_paths[1000]",
298+
"params": {
299+
"uri_count": 1000
300+
},
301+
"param": "1000",
302+
"extra_info": {},
303+
"options": {
304+
"disable_gc": false,
305+
"timer": "perf_counter",
306+
"min_rounds": 5,
307+
"max_time": 1.0,
308+
"min_time": 5e-06,
309+
"warmup": 1
310+
},
311+
"stats": {
312+
"min": 0.0018692729972826783,
313+
"max": 0.0032178769979509525,
314+
"mean": 0.0022238637990085407,
315+
"stddev": 0.0005755831316920673,
316+
"rounds": 5,
317+
"median": 0.001919146001455374,
318+
"iqr": 0.0006023592486599227,
319+
"q1": 0.0018770977494568797,
320+
"q3": 0.0024794569981168024,
321+
"iqr_outliers": 0,
322+
"stddev_outliers": 1,
323+
"outliers": "1;0",
324+
"ld15iqr": 0.0018692729972826783,
325+
"hd15iqr": 0.0032178769979509525,
326+
"ops": 449.66782608081814,
327+
"total": 0.011119318995042704,
328+
"data": [
329+
0.0032178769979509525,
330+
0.0022333169981720857,
331+
0.001919146001455374,
332+
0.0018692729972826783,
333+
0.0018797060001816135
334+
],
335+
"iterations": 1
336+
}
337+
}
338+
],
339+
"datetime": "2025-12-04T18:27:54.380761+00:00",
340+
"version": "5.2.3"
341+
}
-3.45 KB
Loading

0 commit comments

Comments
 (0)