Skip to content

Commit

Permalink
Add const-hex to bench (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhmelody authored Jan 9, 2024
1 parent 9023958 commit b843c98
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
120 changes: 120 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ criterion = { version = "0.5" }
faster-hex = { version = "0.9" }
hex = { version = "0.4" }
rustc-hex = { version = "2.1" }
const-hex = { version = "1.1" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }

Expand Down
8 changes: 8 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fn bench_encode(c: &mut Criterion) {

c.bench_function("hex::encode", |b| b.iter(|| hex::encode(DATA)));

c.bench_function("const_hex::encode", |b| b.iter(|| const_hex::encode(DATA)));

c.bench_function("rustc_hex::to_hex", |b| b.iter(|| DATA.to_hex::<String>()));

c.bench_function("faster_hex::hex_string", |b| b.iter(|| faster_hex::hex_string(DATA)));
Expand Down Expand Up @@ -64,6 +66,12 @@ fn bench_decode(c: &mut Criterion) {
})
});

c.bench_function("const_hex::decode", |b| {
let hex = const_hex::encode(DATA);

b.iter(|| const_hex::decode(&hex).unwrap())
});

c.bench_function("hex::decode", |b| {
let hex = hex::encode(DATA);

Expand Down

0 comments on commit b843c98

Please sign in to comment.