(c: &mut Criterion)
| 178 | } |
| 179 | |
| 180 | pub fn criterion_benchmark(c: &mut Criterion) { |
| 181 | let benchmark_dir = Path::new("./benches/microbenchmarks/"); |
| 182 | let dirs: Vec<fs::DirEntry> = benchmark_dir |
| 183 | .read_dir() |
| 184 | .unwrap() |
| 185 | .collect::<io::Result<_>>() |
| 186 | .unwrap(); |
| 187 | let paths: Vec<PathBuf> = dirs.iter().map(|p| p.path()).collect(); |
| 188 | |
| 189 | let benchmarks: Vec<MicroBenchmark> = paths |
| 190 | .into_iter() |
| 191 | .map(|p| { |
| 192 | let name = p.file_name().unwrap().to_os_string(); |
| 193 | let contents = fs::read_to_string(p).unwrap(); |
| 194 | let iterate = contents.contains("ITERATIONS"); |
| 195 | |
| 196 | let (setup, code) = if contents.contains("# ---") { |
| 197 | let split: Vec<&str> = contents.splitn(2, "# ---").collect(); |
| 198 | (split[0].to_string(), split[1].to_string()) |
| 199 | } else { |
| 200 | ("".to_string(), contents) |
| 201 | }; |
| 202 | let name = name.into_string().unwrap(); |
| 203 | MicroBenchmark { |
| 204 | name, |
| 205 | setup, |
| 206 | code, |
| 207 | iterate, |
| 208 | } |
| 209 | }) |
| 210 | .collect(); |
| 211 | |
| 212 | for benchmark in benchmarks { |
| 213 | if SKIP_MICROBENCHMARKS.contains(&benchmark.name.as_str()) { |
| 214 | continue; |
| 215 | } |
| 216 | run_micro_benchmark(c, benchmark); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | criterion_group!(benches, criterion_benchmark); |
| 221 | criterion_main!(benches); |
nothing calls this directly
no test coverage detected