From b6397ca2bc3b72f04147bc4fe2d608a53927dc25 Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Sat, 18 Jan 2020 18:42:49 +0000 Subject: [PATCH] Isolate the contains call in bench --- benches/parse_bench.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs index e081d4d..fb44534 100644 --- a/benches/parse_bench.rs +++ b/benches/parse_bench.rs @@ -21,18 +21,18 @@ fn parse_ipv4_netmask_benchmark(c: &mut Criterion) { } fn contains_ipv4_benchmark(c: &mut Criterion) { + let cidr = "74.125.227.0/25".parse::().unwrap(); c.bench_function("contains ipv4", |b| { b.iter(|| { - let cidr = "74.125.227.0/25".parse::().unwrap(); cidr.contains(Ipv4Addr::new(74, 125, 227, 4)) }) }); } fn contains_ipv6_benchmark(c: &mut Criterion) { + let cidr = "FF01:0:0:17:0:0:0:2/65".parse::().unwrap(); c.bench_function("contains ipv6", |b| { b.iter(|| { - let cidr = "FF01:0:0:17:0:0:0:2/65".parse::().unwrap(); cidr.contains(Ipv6Addr::new(0xff01, 0, 0, 0x17, 0x7fff, 0, 0, 0x2)) }) });