@@ -14,20 +14,7 @@ fn parseMode(arg: []const u8) !BenchMode {
1414 return error .InvalidBenchMode ;
1515}
1616
17- fn parseDocForParseBench (noalias doc : * Document , input : []u8 , mode : BenchMode ) ! void {
18- switch (mode ) {
19- .strictest = > try doc .parse (input , .{
20- .eager_child_views = true ,
21- .drop_whitespace_text_nodes = false ,
22- }),
23- .fastest = > try doc .parse (input , .{
24- .eager_child_views = false ,
25- .drop_whitespace_text_nodes = true ,
26- }),
27- }
28- }
29-
30- fn parseDocForQueryBench (noalias doc : * Document , input : []u8 , mode : BenchMode ) ! void {
17+ fn parseDocForBench (noalias doc : * Document , input : []u8 , mode : BenchMode ) ! void {
3118 switch (mode ) {
3219 .strictest = > try doc .parse (input , .{
3320 .eager_child_views = true ,
@@ -92,9 +79,9 @@ pub fn runParseFile(path: []const u8, iterations: usize, mode: BenchMode) !u64 {
9279 defer doc .deinit ();
9380 if (working_opt ) | working | {
9481 @memcpy (working , input );
95- try parseDocForParseBench (& doc , working , mode );
82+ try parseDocForBench (& doc , working , mode );
9683 } else {
97- try parseDocForParseBench (& doc , input , mode );
84+ try parseDocForBench (& doc , input , mode );
9885 }
9986 }
10087 _ = parse_arena .reset (.retain_capacity );
@@ -136,7 +123,7 @@ pub fn runQueryMatch(path: []const u8, selector: []const u8, iterations: usize,
136123
137124 var doc = Document .init (alloc );
138125 defer doc .deinit ();
139- try parseDocForQueryBench (& doc , working , mode );
126+ try parseDocForBench (& doc , working , mode );
140127
141128 const start = std .time .nanoTimestamp ();
142129 var i : usize = 0 ;
@@ -166,7 +153,7 @@ pub fn runQueryCompiled(path: []const u8, selector: []const u8, iterations: usiz
166153
167154 var doc = Document .init (alloc );
168155 defer doc .deinit ();
169- try parseDocForQueryBench (& doc , working , mode );
156+ try parseDocForBench (& doc , working , mode );
170157
171158 const start = std .time .nanoTimestamp ();
172159 var i : usize = 0 ;
@@ -198,14 +185,6 @@ pub fn main() !void {
198185 return ;
199186 }
200187
201- if (args .len == 5 and std .mem .eql (u8 , args [1 ], "query-parse" )) {
202- _ = try parseMode (args [2 ]);
203- const iterations = try std .fmt .parseInt (usize , args [4 ], 10 );
204- const total_ns = try runQueryParse (args [3 ], iterations );
205- std .debug .print ("{d}\n " , .{total_ns });
206- return ;
207- }
208-
209188 if (args .len == 5 and std .mem .eql (u8 , args [1 ], "query-match" )) {
210189 const iterations = try std .fmt .parseInt (usize , args [4 ], 10 );
211190 const total_ns = try runQueryMatch (args [2 ], args [3 ], iterations , .fastest );
@@ -246,8 +225,8 @@ pub fn main() !void {
246225
247226 if (args .len != 3 ) {
248227 std .debug .print (
249- "usage:\n {s} <html-file> <iterations>\n {s} parse <strictest|fastest> <html-file> <iterations>\n {s} query-parse <selector> <iterations>\n {s} query-parse <strictest|fastest> <selector> <iterations> \n {s} query- match <html-file> <selector> <iterations>\n {s} query-match <strictest|fastest> <html-file> <selector> <iterations>\n {s} query-compiled <html-file> <selector> <iterations>\n {s} query-compiled <strictest|fastest> <html-file> <selector> <iterations>\n " ,
250- .{ args [0 ], args [0 ], args [0 ], args [0 ], args [0 ], args [0 ], args [0 ], args [ 0 ] },
228+ "usage:\n {s} <html-file> <iterations>\n {s} parse <strictest|fastest> <html-file> <iterations>\n {s} query-parse <selector> <iterations>\n {s} query-match <html-file> <selector> <iterations>\n {s} query-match <strictest|fastest> <html-file> <selector> <iterations>\n {s} query-compiled <html-file> <selector> <iterations>\n {s} query-compiled <strictest|fastest> <html-file> <selector> <iterations>\n " ,
229+ .{ args [0 ], args [0 ], args [0 ], args [0 ], args [0 ], args [0 ], args [0 ] },
251230 );
252231 std .process .exit (2 );
253232 }
0 commit comments