1 2 // Also look in Cargo.toml how to use a benchmark setup with harness = false 3 4 #[macro_use] 5 extern crate bencher; 6 7 use bencher::Bencher; 8 a(bench: &mut Bencher)9fn a(bench: &mut Bencher) { 10 bench.iter(|| { 11 (0..1000).fold(0, |x, y| x + y) 12 }) 13 } 14 b(bench: &mut Bencher)15fn b(bench: &mut Bencher) { 16 const N: usize = 1024; 17 bench.iter(|| { 18 vec![0u8; N] 19 }); 20 21 bench.bytes = N as u64; 22 } 23 24 benchmark_group!(benches, a, b); 25 benchmark_main!(benches); 26 27