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

Function criterion_benchmark

benches/execution.rs:87–121  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

85}
86
87pub 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
123criterion_group!(benches, criterion_benchmark);
124criterion_main!(benches);

Callers

nothing calls this directly

Calls 11

newFunction · 0.85
benchmark_file_parsingFunction · 0.85
benchmark_pystoneFunction · 0.85
benchmark_file_executionFunction · 0.85
to_strMethod · 0.80
mapMethod · 0.45
unwrapMethod · 0.45
pathMethod · 0.45
to_ownedMethod · 0.45
finishMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected