Closed
Description
Fix benchmarks so they don't error
Inspired by @Nyrox's comment #1435 (comment), I spent some time looking at the benchmarks for the SQL parser and found that they were erroring out 😱
So basically the benchmarks are testing the speed of generating errors.
Right now, errors are ignored, but when I changed that I found that the benchmarks were erroring out:
diff --git a/sqlparser_bench/benches/sqlparser_bench.rs b/sqlparser_bench/benches/sqlparser_bench.rs
index 27c58b4..93c18fe 100644
--- a/sqlparser_bench/benches/sqlparser_bench.rs
+++ b/sqlparser_bench/benches/sqlparser_bench.rs
@@ -25,7 +25,7 @@ fn basic_queries(c: &mut Criterion) {
let string = "SELECT * FROM table WHERE 1 = 1";
group.bench_function("sqlparser::select", |b| {
- b.iter(|| Parser::parse_sql(&dialect, string));
+ b.iter(|| Parser::parse_sql(&dialect, string).unwrap());
});
let with_query = "
@@ -40,7 +40,7 @@ fn basic_queries(c: &mut Criterion) {
LEFT JOIN derived USING (user_id)
";
group.bench_function("sqlparser::with_select", |b| {
- b.iter(|| Parser::parse_sql(&dialect, with_query));
+ b.iter(|| Parser::parse_sql(&dialect, with_query).unwrap());
});
}
cargo bench
...
Running benches/sqlparser_bench.rs (target/release/deps/sqlparser_bench-0a4654f932bbac9e)
Gnuplot not found, using plotters backend
Benchmarking sqlparser-rs parsing benchmark/sqlparser::select: Warming up for 3.0000 sthread 'main' panicked at benches/sqlparser_bench.rs:28:55:
called `Result::unwrap()` on an `Err` value: ParserError("Expected: (, found: WHERE at Line: 1, Column: 21")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: bench failed, to rerun pass `--bench sqlparser_bench`
Metadata
Metadata
Assignees
Labels
No labels