Last active
January 8, 2018 17:48
-
-
Save Dowwie/b30e14566fb1461fd964cf4e0793c2a0 to your computer and use it in GitHub Desktop.
bench_maplit_hash.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
extern crate test; | |
#[macro_use] extern crate bencher; | |
#[macro_use] extern crate maplit; | |
use test::Bencher; | |
use std::collections::HashSet; | |
fn test_maplit() -> HashSet<&'static str> { | |
let a = hashset!{"a", "a", "a", "b", "c"}; | |
a | |
} | |
fn test_stdlib() -> HashSet<&'static str> { | |
let b: HashSet<&'static str> = ["a", "a", "a", "b", "c"].iter().cloned().collect(); | |
b | |
} | |
fn main() { | |
let a = test_maplit(); | |
println!("{:?}", a); | |
let b = test_stdlib(); | |
println!("{:?}", b); | |
} | |
#[bench] | |
fn bench_maplit(b: &mut Bencher) { | |
b.iter(|| test_maplit()) | |
} | |
#[bench] | |
fn bench_stdlib(b: &mut Bencher) { | |
b.iter(|| test_stdlib()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment