mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Use stdlib native modules in benchmarks (#6792)
Change benchmark interpreter from without_stdlib to with_init to load Rust-optimized native modules like _json, ensuring benchmarks measure actual optimized performance rather than pure Python fallbacks. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
00440b179a
commit
4ab6a45405
2 files changed
+5
-1
No files matched your search
@@ -54,6 +54,7 @@ rustyline = { workspace = true }
|
||||
[dev-dependencies]
|
||||
criterion = { workspace = true }
|
||||
pyo3 = { version = "0.27", features = ["auto-initialize"] }
|
||||
rustpython-stdlib = { workspace = true }
|
||||
|
||||
[[bench]]
|
||||
name = "execution"
|
||||
|
||||
@@ -24,7 +24,10 @@ fn bench_rustpython_code(b: &mut Bencher, name: &str, source: &str) {
|
||||
settings.path_list.push("Lib/".to_string());
|
||||
settings.write_bytecode = false;
|
||||
settings.user_site_directory = false;
|
||||
Interpreter::without_stdlib(settings).enter(|vm| {
|
||||
Interpreter::with_init(settings, |vm| {
|
||||
vm.add_native_modules(rustpython_stdlib::get_module_inits());
|
||||
})
|
||||
.enter(|vm| {
|
||||
// Note: bench_cpython is both compiling and executing the code.
|
||||
// As such we compile the code in the benchmark loop as well.
|
||||
b.iter(|| {
|
||||
|
||||
Reference in new issue
Block a user