//! Testing `FrequencyMap` performance. // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ #![feature(test)] extern crate rand; extern crate rayon; extern crate test; extern crate xdlol; use xdlol::statistics::FrequencyMap; use test::Bencher; use rand::random; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; #[bench] fn bench_frequency_map_collect_10k(b: &mut Bencher) { let mut test_data: Vec = vec![]; for _ in 0..10000 { test_data.push(random::()); } b.iter(|| { let _freq_map: FrequencyMap = test_data.iter().cloned().collect(); }); } #[bench] fn bench_frequency_map_collect_20k(b: &mut Bencher) { let mut test_data: Vec = vec![]; for _ in 0..20000 { test_data.push(random::()); } b.iter(|| { let _freq_map: FrequencyMap = test_data.iter().cloned().collect(); }); }