diff options
author | Griffin Smith <root@gws.fyi> | 2022-09-02T19·02-0400 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-09-03T06·56+0000 |
commit | 3270817b9053cc0d656bf9f8522e81a2917b3036 (patch) | |
tree | 1c96e9eb83ec9461e2b501def517884e1de61474 /tvix/eval/benches | |
parent | 48b0fac76bd1444eac7dd082b699e0ec41fbfdd3 (diff) |
test(tvix/eval): Add attr merge benchmarks r/4615
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>
Diffstat (limited to 'tvix/eval/benches')
-rw-r--r-- | tvix/eval/benches/eval.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tvix/eval/benches/eval.rs b/tvix/eval/benches/eval.rs index a05c04f03e29..9be381e0f803 100644 --- a/tvix/eval/benches/eval.rs +++ b/tvix/eval/benches/eval.rs @@ -1,9 +1,25 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use itertools::Itertools; use tvix_eval::interpret; fn eval_literals(c: &mut Criterion) { 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); |