use std::collections::BTreeMap; use energy_bench::EnergyBenchBuilder; use rand::distributions::{Distribution, Uniform}; pub fn uniform(size: usize) -> Vec { let range = Uniform::new(i64::MIN, i64::MAX); let mut rng = rand::thread_rng(); (0..size).map(|_| range.sample(&mut rng)).collect() } fn insert(vec: Vec) -> BTreeMap { let mut set = BTreeMap::new(); vec.iter().for_each(|&value| { let key = value.to_string(); set.insert(key, value); }); set } fn main() { let mut bench = EnergyBenchBuilder::new("tree") .with_number_of_measurements(5) .build(); const SIZES: [usize; 3] = [10000, 100000, 1000000]; for size in SIZES { bench.benchmark(size, &|| uniform(size), &insert); } }