tvl-depot/tvix/eval/benches/eval.rs
Griffin Smith e720545e5b refactor(tvix/eval): use Clap for arg+env parsing
Refactor the environment variable and argument parsing for the tvix repl
to use Clap instead of doing things ad-hoc, and thread through options
obtained from environment variables via explicit arguments rather than
obtaining them from the environment as they're needed. This makes adding
more flags more sustainable, and also makes the binary fully
self-documenting, including supported env vars, via `--help`.

Change-Id: Ib1f6a0cd20056e8c9196760ff755fa5729667760
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6653
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-18 22:08:43 +00:00

33 lines
1,000 B
Rust

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, Default::default())))
});
}
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,
Default::default(),
))
})
});
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, Default::default())))
});
}
criterion_group!(benches, eval_literals, eval_merge_attrs);
criterion_main!(benches);