test(tvix/eval): Add attr merge benchmarks
Add a quick couple of benchmarks for merging attribute sets, large and small. Change-Id: I26940a9cf4e0d30e3d9eb07a7b8c366ca4072ca3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6286 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: grfn <grfn@gws.fyi>
This commit is contained in:
parent
48b0fac76b
commit
3270817b90
3 changed files with 19 additions and 1 deletions
1
tvix/eval/Cargo.lock
generated
1
tvix/eval/Cargo.lock
generated
|
@ -874,6 +874,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion",
|
"criterion",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"itertools",
|
||||||
"path-clean",
|
"path-clean",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rnix",
|
"rnix",
|
||||||
|
|
|
@ -23,6 +23,7 @@ rev = "614e7d4641e83ab7eb321d9ac5e3d12985f9f3ba"
|
||||||
criterion = "0.3.6"
|
criterion = "0.3.6"
|
||||||
test-generator = "0.3.0"
|
test-generator = "0.3.0"
|
||||||
pretty_assertions = "1.2.1"
|
pretty_assertions = "1.2.1"
|
||||||
|
itertools = "0.10.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Enables running the Nix language test suite from the original C++
|
# Enables running the Nix language test suite from the original C++
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use itertools::Itertools;
|
||||||
use tvix_eval::interpret;
|
use tvix_eval::interpret;
|
||||||
|
|
||||||
fn eval_literals(c: &mut Criterion) {
|
fn eval_literals(c: &mut Criterion) {
|
||||||
c.bench_function("int", |b| b.iter(|| black_box(interpret("42", None))));
|
c.bench_function("int", |b| b.iter(|| black_box(interpret("42", None))));
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, eval_literals);
|
fn eval_merge_attrs(c: &mut Criterion) {
|
||||||
|
c.bench_function("merge small attrs", |b| {
|
||||||
|
b.iter(|| black_box(interpret("{ a = 1; b = 2; } // { c = 3; }", None)))
|
||||||
|
});
|
||||||
|
|
||||||
|
c.bench_function("merge large attrs with small attrs", |b| {
|
||||||
|
let large_attrs = format!(
|
||||||
|
"{{{}}}",
|
||||||
|
(0..10000).map(|n| format!("a{n} = {n};")).join(" ")
|
||||||
|
);
|
||||||
|
let expr = format!("{large_attrs} // {{ c = 3; }}");
|
||||||
|
b.iter(move || black_box(interpret(&expr, None)))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, eval_literals, eval_merge_attrs);
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
|
Loading…
Reference in a new issue