MCPcopy Index your code
hub / github.com/RustPython/RustPython / criterion_benchmark

Function criterion_benchmark

benches/microbenchmarks.rs:180–218  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

178}
179
180pub 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
220criterion_group!(benches, criterion_benchmark);
221criterion_main!(benches);

Callers

nothing calls this directly

Calls 13

newFunction · 0.85
run_micro_benchmarkFunction · 0.85
collectMethod · 0.80
splitnMethod · 0.80
to_stringMethod · 0.80
into_stringMethod · 0.80
unwrapMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
pathMethod · 0.45
into_iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected