vendor sqlite3-parser (lemon-rs)

This commit is contained in:
jussisaurio
2024-11-16 13:22:26 +02:00
parent 8efeb16b82
commit 3cc9d9d79f
38 changed files with 15973 additions and 37 deletions

View File

@@ -0,0 +1,19 @@
[package]
name = "sqlparser_bench"
version = "0.1.0"
authors = ["Dandandan <danielheres@gmail.com>"]
edition = "2018"
[dependencies]
sqlite3-parser = { path = "..", default-features = false, features = [
"YYNOERRORRECOVERY",
"NDEBUG",
] }
fallible-iterator = "0.3"
[dev-dependencies]
criterion = "0.5"
[[bench]]
name = "sqlparser_bench"
harness = false

View File

@@ -0,0 +1,32 @@
Adapted from https://github.com/ballista-compute/sqlparser-rs/tree/main/sqlparser_bench
## sqlparser-rs
```
sqlparser-rs parsing benchmark/sqlparser::select
time: [9.9697 µs 10.068 µs 10.184 µs]
Found 14 outliers among 100 measurements (14.00%)
5 (5.00%) high mild
9 (9.00%) high severe
sqlparser-rs parsing benchmark/sqlparser::with_select
time: [59.569 µs 60.088 µs 60.743 µs]
Found 9 outliers among 100 measurements (9.00%)
3 (3.00%) high mild
6 (6.00%) high severe
```
## sqlite3-parser
```
sqlparser-rs parsing benchmark/sqlparser::select
time: [6.5488 µs 6.5773 µs 6.6108 µs]
Found 10 outliers among 100 measurements (10.00%)
4 (4.00%) high mild
6 (6.00%) high severe
sqlparser-rs parsing benchmark/sqlparser::with_select
time: [22.182 µs 22.321 µs 22.473 µs]
Found 8 outliers among 100 measurements (8.00%)
1 (1.00%) low mild
3 (3.00%) high mild
4 (4.00%) high severe
```

View File

@@ -0,0 +1,48 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use criterion::{criterion_group, criterion_main, Criterion};
use fallible_iterator::FallibleIterator;
use sqlite3_parser::lexer::sql::Parser;
fn basic_queries(c: &mut Criterion) {
let mut group = c.benchmark_group("sqlparser-rs parsing benchmark");
let string = b"SELECT * FROM `table` WHERE 1 = 1";
group.bench_with_input("sqlparser::select", &string, |b, &s| {
b.iter(|| {
let mut parser = Parser::new(s);
assert!(parser.next().unwrap().unwrap().readonly())
});
});
let with_query = b"
WITH derived AS (
SELECT MAX(a) AS max_a,
COUNT(b) AS b_num,
user_id
FROM `TABLE`
GROUP BY user_id
)
SELECT * FROM `table`
LEFT JOIN derived USING (user_id)
";
group.bench_with_input("sqlparser::with_select", &with_query, |b, &s| {
b.iter(|| {
let mut parser = Parser::new(s);
assert!(parser.next().unwrap().unwrap().readonly())
});
});
}
criterion_group!(benches, basic_queries);
criterion_main!(benches);