summaryrefslogtreecommitdiffstats
path: root/vendor/base16ct/benches/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/base16ct/benches/mod.rs')
-rw-r--r--vendor/base16ct/benches/mod.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/base16ct/benches/mod.rs b/vendor/base16ct/benches/mod.rs
new file mode 100644
index 000000000..75af0c9db
--- /dev/null
+++ b/vendor/base16ct/benches/mod.rs
@@ -0,0 +1,69 @@
+#![feature(test)]
+extern crate test;
+
+use test::{black_box, Bencher};
+
+#[bench]
+fn decode_lower(b: &mut Bencher) {
+ let input = vec![b'1'; 1 << 14];
+ let mut buf = vec![0u8; 1 << 13];
+
+ b.iter(|| {
+ let input = black_box(&input[..]);
+ let res = base16ct::lower::decode(input, &mut buf).unwrap();
+ black_box(res);
+ });
+ b.bytes = input.len() as u64;
+}
+
+#[bench]
+fn decode_upper(b: &mut Bencher) {
+ let input = vec![b'1'; 1 << 14];
+ let mut buf = vec![0u8; 1 << 13];
+
+ b.iter(|| {
+ let input = black_box(&input[..]);
+ let res = base16ct::upper::decode(input, &mut buf).unwrap();
+ black_box(res);
+ });
+ b.bytes = input.len() as u64;
+}
+
+#[bench]
+fn decode_mixed(b: &mut Bencher) {
+ let input = vec![b'1'; 1 << 14];
+ let mut buf = vec![0u8; 1 << 13];
+
+ b.iter(|| {
+ let input = black_box(&input[..]);
+ let res = base16ct::mixed::decode(input, &mut buf).unwrap();
+ black_box(res);
+ });
+ b.bytes = input.len() as u64;
+}
+
+#[bench]
+fn encode_lower(b: &mut Bencher) {
+ let input = vec![0x42; 1 << 14];
+ let mut buf = vec![0u8; 1 << 15];
+
+ b.iter(|| {
+ let input = black_box(&input[..]);
+ let res = base16ct::lower::encode(input, &mut buf).unwrap();
+ black_box(res);
+ });
+ b.bytes = input.len() as u64;
+}
+
+#[bench]
+fn encode_upper(b: &mut Bencher) {
+ let input = vec![0x42; 1 << 14];
+ let mut buf = vec![0u8; 1 << 15];
+
+ b.iter(|| {
+ let input = black_box(&input[..]);
+ let res = base16ct::upper::encode(input, &mut buf).unwrap();
+ black_box(res);
+ });
+ b.bytes = input.len() as u64;
+}