(c: &mut Criterion)
| 85 | } |
| 86 | |
| 87 | pub fn criterion_benchmark(c: &mut Criterion) { |
| 88 | let benchmark_dir = Path::new("./benches/benchmarks/"); |
| 89 | let mut benches = benchmark_dir |
| 90 | .read_dir() |
| 91 | .unwrap() |
| 92 | .map(|entry| { |
| 93 | let path = entry.unwrap().path(); |
| 94 | ( |
| 95 | path.file_name().unwrap().to_str().unwrap().to_owned(), |
| 96 | std::fs::read_to_string(path).unwrap(), |
| 97 | ) |
| 98 | }) |
| 99 | .collect::<HashMap<_, _>>(); |
| 100 | |
| 101 | // Benchmark parsing |
| 102 | let mut parse_group = c.benchmark_group("parse_to_ast"); |
| 103 | for (name, contents) in &benches { |
| 104 | benchmark_file_parsing(&mut parse_group, name, contents); |
| 105 | } |
| 106 | parse_group.finish(); |
| 107 | |
| 108 | // Benchmark PyStone |
| 109 | if let Some(pystone_contents) = benches.remove("pystone.py") { |
| 110 | let mut pystone_group = c.benchmark_group("pystone"); |
| 111 | benchmark_pystone(&mut pystone_group, pystone_contents); |
| 112 | pystone_group.finish(); |
| 113 | } |
| 114 | |
| 115 | // Benchmark execution |
| 116 | let mut execution_group = c.benchmark_group("execution"); |
| 117 | for (name, contents) in &benches { |
| 118 | benchmark_file_execution(&mut execution_group, name, contents); |
| 119 | } |
| 120 | execution_group.finish(); |
| 121 | } |
| 122 | |
| 123 | criterion_group!(benches, criterion_benchmark); |
| 124 | criterion_main!(benches); |
nothing calls this directly
no test coverage detected