@@ -111,48 +111,41 @@ def run_benchmark():
111111
112112 # End-to-end: Template -> DOM -> String
113113 results ["full_pipeline" ] = benchmark_operation (
114- "Full pipeline (template → DOM → HTML)" ,
115- lambda : str (html (template ))
114+ "Full pipeline (template → DOM → HTML)" , lambda : str (html (template ))
116115 )
117116
118117 # Just parsing: Template -> DOM
119118 results ["parse_only" ] = benchmark_operation (
120- "Parse only (template → DOM)" ,
121- lambda : html (template )
119+ "Parse only (template → DOM)" , lambda : html (template )
122120 )
123121
124122 # Just serialization: DOM -> String
125123 dom = html (template )
126124 results ["serialize_only" ] = benchmark_operation (
127- "Serialize only (DOM → HTML)" ,
128- lambda : str (dom )
125+ "Serialize only (DOM → HTML)" , lambda : str (dom )
129126 )
130127
131128 # Small template (overhead measurement)
132129 small_template = t "<div><p>Hello</p></div>"
133130 results ["small_template" ] = benchmark_operation (
134- "Small template (overhead baseline)" ,
135- lambda : str (html (small_template ))
131+ "Small template (overhead baseline)" , lambda : str (html (small_template ))
136132 )
137133
138134 # Heavy interpolation
139135 results ["interpolation" ] = benchmark_operation (
140- "Heavy interpolation" ,
141- lambda : str (html (interpolation_template ))
136+ "Heavy interpolation" , lambda : str (html (interpolation_template ))
142137 )
143138
144139 # Component rendering (nested elements)
145140 nested_template = t "<div><div><div><p>Nested</p></div></div></div>"
146141 results ["nested" ] = benchmark_operation (
147- "Nested elements" ,
148- lambda : str (html (nested_template ))
142+ "Nested elements" , lambda : str (html (nested_template ))
149143 )
150144
151145 # Attribute handling
152146 attr_template = t '<div id="test" class="foo bar" data-value="123">Content</div>'
153147 results ["attributes" ] = benchmark_operation (
154- "Attribute handling" ,
155- lambda : str (html (attr_template ))
148+ "Attribute handling" , lambda : str (html (attr_template ))
156149 )
157150
158151 print ("-" * 80 )
@@ -173,9 +166,7 @@ def run_benchmark():
173166 else :
174167 print (" ✗ SLOW - Optimization recommended" )
175168
176- print (
177- f"\n Current: { avg_time :.1f} μs/op | Target: <100μs/op | Best: <50μs/op"
178- )
169+ print (f"\n Current: { avg_time :.1f} μs/op | Target: <100μs/op | Best: <50μs/op" )
179170
180171 # Detailed breakdown
181172 print ("\n " + "=" * 80 )
@@ -187,9 +178,13 @@ def run_benchmark():
187178 full_time = results ["full_pipeline" ]
188179 overhead = full_time - (parse_time + serialize_time )
189180
190- print (f"\n Parsing: { parse_time :>8.3f} μs ({ parse_time / full_time * 100 :.1f} %)" )
191- print (f"Serialization: { serialize_time :>8.3f} μs ({ serialize_time / full_time * 100 :.1f} %)" )
192- print (f"Overhead: { overhead :>8.3f} μs ({ overhead / full_time * 100 :.1f} %)" )
181+ print (
182+ f"\n Parsing: { parse_time :>8.3f} μs ({ parse_time / full_time * 100 :.1f} %)"
183+ )
184+ print (
185+ f"Serialization: { serialize_time :>8.3f} μs ({ serialize_time / full_time * 100 :.1f} %)"
186+ )
187+ print (f"Overhead: { overhead :>8.3f} μs ({ overhead / full_time * 100 :.1f} %)" )
193188 print (f"Total: { full_time :>8.3f} μs (100.0%)" )
194189
195190
0 commit comments