Skip to content

Commit

Permalink
added benches
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed May 19, 2017
1 parent 7328c1d commit ddfb992
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions benches/hex.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![feature(test)]

extern crate test;
extern crate rustc_hex as hex;

use test::Bencher;
use hex::{FromHex, ToHex};

#[bench]
fn bench_to_hex(b: &mut Bencher) {
let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
b.iter(|| {
s.as_bytes().to_hex();
});
b.bytes = s.len() as u64;
}

#[bench]
fn bench_from_hex(b: &mut Bencher) {
let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
let sb = s.as_bytes().to_hex();
b.iter(|| {
sb.from_hex().unwrap();
});
b.bytes = sb.len() as u64;
}

0 comments on commit ddfb992

Please sign in to comment.