Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add encode/decode bench for rustc-hex #15

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ faster-hex = { version = "0.10.0", default-features = false, features = [
] }
hex = { version = "~0.4.2", default-features = false }
hex-literal = "0.4"
rustc-hex = "2.1"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }

Expand Down
26 changes: 26 additions & 0 deletions benches/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ macro_rules! benches {
}
)*
}

mod rustc_hex {
use super::*;

$(
#[bench]
fn $name(b: &mut Bencher) {
b.iter(|| {
::rustc_hex::FromHex::from_hex::<Vec<_>>(black_box($dec))
});
}
)*
}
}

mod decode_to_slice {
Expand Down Expand Up @@ -209,6 +222,19 @@ macro_rules! benches {
}
)*
}

mod rustc_hex {
use super::*;

$(
#[bench]
fn $name(b: &mut Bencher) {
b.iter(|| {
::rustc_hex::ToHex::to_hex::<String>(&black_box($enc)[..])
});
}
)*
}
}

mod encode_to_slice {
Expand Down