]> git.proxmox.com Git - rustc.git/blobdiff - src/libcore/benches/hash/sip.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / libcore / benches / hash / sip.rs
index 5baba42763e102e5a08b97b381a316a4e97bac5f..725c864dce9f151f976abed386be6071e4531a8c 100644 (file)
@@ -1,7 +1,7 @@
 #![allow(deprecated)]
 
 use core::hash::*;
-use test::{Bencher, black_box};
+use test::{black_box, Bencher};
 
 fn hash_bytes<H: Hasher>(mut s: H, x: &[u8]) -> u64 {
     Hasher::write(&mut s, x);
@@ -44,11 +44,11 @@ fn bench_str_over_8_bytes(b: &mut Bencher) {
 #[bench]
 fn bench_long_str(b: &mut Bencher) {
     let s = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \
-incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
-exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \
-irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \
-pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
-officia deserunt mollit anim id est laborum.";
+             incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
+             exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \
+             irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \
+             pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
+             officia deserunt mollit anim id est laborum.";
     b.iter(|| {
         assert_eq!(hash(&s), 17717065544121360093);
     })
@@ -58,9 +58,7 @@ officia deserunt mollit anim id est laborum.";
 fn bench_u32(b: &mut Bencher) {
     let u = 162629500u32;
     let u = black_box(u);
-    b.iter(|| {
-        hash(&u)
-    });
+    b.iter(|| hash(&u));
     b.bytes = 8;
 }
 
@@ -70,9 +68,7 @@ fn bench_u32_keyed(b: &mut Bencher) {
     let u = black_box(u);
     let k1 = black_box(0x1);
     let k2 = black_box(0x2);
-    b.iter(|| {
-        hash_with(SipHasher::new_with_keys(k1, k2), &u)
-    });
+    b.iter(|| hash_with(SipHasher::new_with_keys(k1, k2), &u));
     b.bytes = 8;
 }
 
@@ -80,62 +76,48 @@ fn bench_u32_keyed(b: &mut Bencher) {
 fn bench_u64(b: &mut Bencher) {
     let u = 16262950014981195938u64;
     let u = black_box(u);
-    b.iter(|| {
-        hash(&u)
-    });
+    b.iter(|| hash(&u));
     b.bytes = 8;
 }
 
 #[bench]
 fn bench_bytes_4(b: &mut Bencher) {
     let data = black_box([b' '; 4]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 4;
 }
 
 #[bench]
 fn bench_bytes_7(b: &mut Bencher) {
     let data = black_box([b' '; 7]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 7;
 }
 
 #[bench]
 fn bench_bytes_8(b: &mut Bencher) {
     let data = black_box([b' '; 8]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 8;
 }
 
 #[bench]
 fn bench_bytes_a_16(b: &mut Bencher) {
     let data = black_box([b' '; 16]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 16;
 }
 
 #[bench]
 fn bench_bytes_b_32(b: &mut Bencher) {
     let data = black_box([b' '; 32]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 32;
 }
 
 #[bench]
 fn bench_bytes_c_128(b: &mut Bencher) {
     let data = black_box([b' '; 128]);
-    b.iter(|| {
-        hash_bytes(SipHasher::default(), &data)
-    });
+    b.iter(|| hash_bytes(SipHasher::default(), &data));
     b.bytes = 128;
 }