Files
hickory-dns/crates/proto/benches/name_benches.rs
Benjamin Fry 408d0baca0 Prepare 0.24 release with branding change to Hickory DNS (#2054)
* update all READMEs with notices about the name change

* update changelog for 0.24

* bump crate versions to 0.24

* update version notice information

* update readmes to back reference trust-dns

* rename all crates to hickory counterparts

* replace all Trust-DNS references in code and comments with Hickory DNS

* rename all Trust-DNS references to Hickory DNS in non-code

* rename all trust-dns-resolver references to hickory-resolver

* rename all trust-dns-client references to hickory-client

* rename all trust-dns-proto references to hickory-proto

* rename all trust-dns-server references to hickory-server

* rename all trust-dns-compatibility references to hickory-compatability

* rename all trust-dns-integration references to hickory-integration

* rename all trust-dns-util references to hickory-util

* Update MIT licenses to reference Hickory DNS

* update all trust-dns references to hickory-dns

* update all bluejekyll github references to hickorydns org

* Update name in Changelog

* make sure hickory-dns logs during tests

* add changelogs for recent main additions

* fix references to trust-dns and hickory in architecture

* update a few trust-dns references in READMEs

* fixup some dangling trust_dns references

* replace fka with formerly in change log

* replace all hickoydns org references to hickory-dns

* replace all http links with https

* update logos

* update hickorydns to hickory-dns for all other org references

* fix Notices of Trust-DNS to Hickory in each Readme
2023-10-13 18:39:28 -07:00

161 lines
3.7 KiB
Rust

#![cfg(nightly)]
#![feature(test)]
extern crate test;
use std::cmp::Ordering;
use test::Bencher;
use hickory_proto::rr::*;
#[bench]
fn name_cmp_short(b: &mut Bencher) {
let name1 = Name::from_ascii("com").unwrap();
let name2 = Name::from_ascii("COM").unwrap();
b.iter(|| {
assert_eq!(name1.cmp(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_short_not_eq(b: &mut Bencher) {
let name1 = Name::from_ascii("com").unwrap();
let name2 = Name::from_ascii("COM").unwrap();
b.iter(|| {
assert_ne!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_short_case(b: &mut Bencher) {
let name1 = Name::from_ascii("com").unwrap();
let name2 = Name::from_ascii("com").unwrap();
b.iter(|| {
assert_eq!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_medium(b: &mut Bencher) {
let name1 = Name::from_ascii("www.example.com").unwrap();
let name2 = Name::from_ascii("www.EXAMPLE.com").unwrap();
b.iter(|| {
assert_eq!(name1.cmp(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_medium_not_eq(b: &mut Bencher) {
let name1 = Name::from_ascii("www.example.com").unwrap();
let name2 = Name::from_ascii("www.EXAMPLE.com").unwrap();
b.iter(|| {
assert_ne!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_medium_case(b: &mut Bencher) {
let name1 = Name::from_ascii("www.example.com").unwrap();
let name2 = Name::from_ascii("www.example.com").unwrap();
b.iter(|| {
assert_eq!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_long(b: &mut Bencher) {
let name1 = Name::from_ascii("a.crazy.really.long.example.com").unwrap();
let name2 = Name::from_ascii("a.crazy.really.long.EXAMPLE.com").unwrap();
b.iter(|| {
assert_eq!(name1.cmp(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_long_not_eq(b: &mut Bencher) {
let name1 = Name::from_ascii("a.crazy.really.long.example.com").unwrap();
let name2 = Name::from_ascii("a.crazy.really.long.EXAMPLE.com").unwrap();
b.iter(|| {
assert_ne!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_cmp_long_case(b: &mut Bencher) {
let name1 = Name::from_ascii("a.crazy.really.long.example.com").unwrap();
let name2 = Name::from_ascii("a.crazy.really.long.example.com").unwrap();
b.iter(|| {
assert_eq!(name1.cmp_case(&name2), Ordering::Equal);
});
}
#[bench]
fn name_to_lower_short(b: &mut Bencher) {
let name1 = Name::from_ascii("COM").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 1);
});
}
#[bench]
fn name_to_lower_medium(b: &mut Bencher) {
let name1 = Name::from_ascii("example.COM").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 2);
});
}
#[bench]
fn name_to_lower_long(b: &mut Bencher) {
let name1 = Name::from_ascii("www.EXAMPLE.com").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 3);
});
}
#[bench]
fn name_no_lower_short(b: &mut Bencher) {
let name1 = Name::from_ascii("com").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 1);
});
}
#[bench]
fn name_no_lower_medium(b: &mut Bencher) {
let name1 = Name::from_ascii("example.com").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 2);
});
}
#[bench]
fn name_no_lower_long(b: &mut Bencher) {
let name1 = Name::from_ascii("www.example.com").unwrap();
b.iter(|| {
let lower = name1.to_lowercase();
assert_eq!(lower.num_labels(), 3);
});
}