From ae839983818d69852d733c23794d74933bcfe74e Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 28 Oct 2023 16:03:16 +0000 Subject: fix(nix-compat/narinfo): unwrap in the benchmark We primarily want to measure the speed of the happy path. Change-Id: Iad0146dde86fc262e2a4b8295bde4eb297b8bf30 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9866 Reviewed-by: flokli Tested-by: BuildkiteCI Autosubmit: edef --- tvix/nix-compat/benches/narinfo_parse.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tvix/nix-compat/benches') diff --git a/tvix/nix-compat/benches/narinfo_parse.rs b/tvix/nix-compat/benches/narinfo_parse.rs index 974d77b6d78b..7ffd24d12bc3 100644 --- a/tvix/nix-compat/benches/narinfo_parse.rs +++ b/tvix/nix-compat/benches/narinfo_parse.rs @@ -35,7 +35,7 @@ pub fn parse(c: &mut Criterion) { g.throughput(Throughput::Bytes(SAMPLE.len() as u64)); g.bench_with_input("single", SAMPLE, |b, data| { b.iter(|| { - black_box(NarInfo::parse(black_box(data))); + black_box(NarInfo::parse(black_box(data)).ok().unwrap()); }); }); } @@ -52,7 +52,11 @@ pub fn parse(c: &mut Criterion) { let mut vec = vec![]; b.iter(|| { vec.clear(); - vec.extend(black_box(data).iter().map(|s| NarInfo::parse(s))); + vec.extend( + black_box(data) + .iter() + .map(|s| NarInfo::parse(s).ok().unwrap()), + ); black_box(&vec); }); }); -- cgit 1.4.1