Skip to content

Commit

Permalink
chore: add encode/decode bench for rustc-hex
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Oct 6, 2024
1 parent 85f0814 commit e28fd09
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit e28fd09

Please sign in to comment.