mirror of
https://github.com/allankoechke/turso.git
synced 2026-12-02 01:41:42 +00:00
inferno is licensed under CDDL-1.0, which is not allowed in the source tree. It was pulled in only by the flamegraph feature of pprof, which the core and SQL parser benches used to write a flamegraph during cargo bench --profile-time. Drop the profiler from those benches and remove pprof from the core and parser dev-dependencies. The FTS benchmark tool keeps pprof without the flamegraph feature, since it writes collapsed stacks itself and does not depend on inferno. The codspeed and non-codspeed criterion groups in most benches differed only by the profiler, so they are merged into one group where the result is identical.
84 lines
2.5 KiB
Rust
84 lines
2.5 KiB
Rust
#[cfg(not(feature = "codspeed"))]
|
|
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
|
|
#[cfg(feature = "codspeed")]
|
|
use codspeed_criterion_compat::{
|
|
black_box, criterion_group, criterion_main, BenchmarkId, Criterion,
|
|
};
|
|
|
|
use turso_parser::{lexer::Lexer, parser::Parser};
|
|
|
|
#[turso_macros::codspeed_criterion_benchmark]
|
|
fn bench_parser(criterion: &mut Criterion) {
|
|
let queries = [
|
|
"SELECT 1",
|
|
"SELECT * FROM users LIMIT 1",
|
|
"SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY count(1) LIMIT 1",
|
|
];
|
|
|
|
for query in queries.iter() {
|
|
let mut group = criterion.benchmark_group(format!("Parser `{query}`"));
|
|
let qb = query.as_bytes();
|
|
|
|
group.bench_function(BenchmarkId::new("limbo_parser_query", ""), |b| {
|
|
b.iter(|| Parser::new(black_box(qb)).next().unwrap());
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
}
|
|
|
|
#[turso_macros::codspeed_criterion_benchmark]
|
|
fn bench_parser_insert_batch(criterion: &mut Criterion) {
|
|
for batch_size in [1, 10, 100] {
|
|
let mut values = String::from("INSERT INTO test VALUES ");
|
|
for i in 0..batch_size {
|
|
if i > 0 {
|
|
values.push(',');
|
|
}
|
|
values.push_str(&format!("({}, '{}')", i, format_args!("value_{i}")));
|
|
}
|
|
|
|
let mut group = criterion.benchmark_group(format!("Parser insert batch `{values}`"));
|
|
let qb = values.as_bytes();
|
|
|
|
group.bench_function(BenchmarkId::new("limbo_parser_insert_batch", ""), |b| {
|
|
b.iter(|| Parser::new(black_box(qb)).next().unwrap());
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
}
|
|
|
|
#[turso_macros::codspeed_criterion_benchmark]
|
|
fn bench_lexer(criterion: &mut Criterion) {
|
|
let queries = [
|
|
"SELECT 1",
|
|
"SELECT * FROM users LIMIT 1",
|
|
"SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY count(1) LIMIT 1",
|
|
];
|
|
|
|
for query in queries.iter() {
|
|
let mut group = criterion.benchmark_group(format!("Lexer `{query}`"));
|
|
let qb = query.as_bytes();
|
|
|
|
group.bench_function(BenchmarkId::new("limbo_lexer_query", ""), |b| {
|
|
b.iter(|| {
|
|
for token in Lexer::new(black_box(qb)) {
|
|
token.unwrap();
|
|
}
|
|
});
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
}
|
|
|
|
criterion_group! {
|
|
name = benches;
|
|
config = Criterion::default();
|
|
targets = bench_parser, bench_parser_insert_batch, bench_lexer
|
|
}
|
|
|
|
criterion_main!(benches);
|