mirror of
https://github.com/achanda/ipnetwork.git
synced 2025-06-15 00:26:33 +00:00
Isolate the contains call in bench
This commit is contained in:
@ -21,18 +21,18 @@ fn parse_ipv4_netmask_benchmark(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn contains_ipv4_benchmark(c: &mut Criterion) {
|
fn contains_ipv4_benchmark(c: &mut Criterion) {
|
||||||
|
let cidr = "74.125.227.0/25".parse::<Ipv4Network>().unwrap();
|
||||||
c.bench_function("contains ipv4", |b| {
|
c.bench_function("contains ipv4", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let cidr = "74.125.227.0/25".parse::<Ipv4Network>().unwrap();
|
|
||||||
cidr.contains(Ipv4Addr::new(74, 125, 227, 4))
|
cidr.contains(Ipv4Addr::new(74, 125, 227, 4))
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_ipv6_benchmark(c: &mut Criterion) {
|
fn contains_ipv6_benchmark(c: &mut Criterion) {
|
||||||
|
let cidr = "FF01:0:0:17:0:0:0:2/65".parse::<Ipv6Network>().unwrap();
|
||||||
c.bench_function("contains ipv6", |b| {
|
c.bench_function("contains ipv6", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let cidr = "FF01:0:0:17:0:0:0:2/65".parse::<Ipv6Network>().unwrap();
|
|
||||||
cidr.contains(Ipv6Addr::new(0xff01, 0, 0, 0x17, 0x7fff, 0, 0, 0x2))
|
cidr.contains(Ipv6Addr::new(0xff01, 0, 0, 0x17, 0x7fff, 0, 0, 0x2))
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user