fix(tvix/eval/benches): use black_box properly
The purpose of black_box is to actually prevent the compiler from being able to optimize computation of the benchmarked function away. To accomplish this, we need to actually *use* black_box to blackbox the input data away, rather than the return type. Change-Id: I5438982f57509fbf7b85034346a2739d76aef1fa Reviewed-on: https://cl.tvl.fyi/c/depot/+/9902 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
524acf0337
commit
1571d7195e
1 changed files with 3 additions and 6 deletions
|
@ -8,8 +8,7 @@ fn interpret(code: &str) {
|
|||
fn eval_literals(c: &mut Criterion) {
|
||||
c.bench_function("int", |b| {
|
||||
b.iter(|| {
|
||||
interpret("42");
|
||||
black_box(())
|
||||
interpret(black_box("42"));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -17,8 +16,7 @@ fn eval_literals(c: &mut Criterion) {
|
|||
fn eval_merge_attrs(c: &mut Criterion) {
|
||||
c.bench_function("merge small attrs", |b| {
|
||||
b.iter(|| {
|
||||
interpret("{ a = 1; b = 2; } // { c = 3; }");
|
||||
black_box(())
|
||||
interpret(black_box("{ a = 1; b = 2; } // { c = 3; }"));
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -29,8 +27,7 @@ fn eval_merge_attrs(c: &mut Criterion) {
|
|||
);
|
||||
let expr = format!("{large_attrs} // {{ c = 3; }}");
|
||||
b.iter(move || {
|
||||
interpret(&expr);
|
||||
black_box(())
|
||||
interpret(black_box(&expr));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue