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

Function bench_cpython_code

benches/execution.rs:9–19  ·  view source on GitHub ↗
(b: &mut Bencher, source: &str)

Source from the content-addressed store, hash-verified

7use std::{collections::HashMap, hint::black_box, path::Path};
8
9fn bench_cpython_code(b: &mut Bencher, source: &str) {
10 let c_str_source_head = std::ffi::CString::new(source).unwrap();
11 let c_str_source = c_str_source_head.as_c_str();
12 pyo3::Python::attach(|py| {
13 b.iter(|| {
14 let module = pyo3::types::PyModule::from_code(py, c_str_source, c"", c"")
15 .expect("Error running source");
16 black_box(module);
17 })
18 })
19}
20
21fn bench_rustpython_code(b: &mut Bencher, name: &str, source: &str) {
22 // NOTE: Take long time.

Callers 2

benchmark_file_executionFunction · 0.70
benchmark_pystoneFunction · 0.70

Calls 3

newFunction · 0.85
unwrapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected