From a50b91bb0e02bb6c615aa2d4bfdd4048d4dab2e1 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Sun, 24 Oct 2021 01:47:12 -0400 Subject: [PATCH] Make `benchmark` work with `act`, and fix import This doesn't remedy a certain benchmark's possible memory consumption. --- .github/workflows/cron-ci.yaml | 1 + benches/microbenchmarks.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cron-ci.yaml b/.github/workflows/cron-ci.yaml index 4ba635ac2..482c6140a 100644 --- a/.github/workflows/cron-ci.yaml +++ b/.github/workflows/cron-ci.yaml @@ -124,6 +124,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 - run: cargo install cargo-criterion - name: build benchmarks run: cargo build --release --benches diff --git a/benches/microbenchmarks.rs b/benches/microbenchmarks.rs index d8d3086d0..ddfdb57c2 100644 --- a/benches/microbenchmarks.rs +++ b/benches/microbenchmarks.rs @@ -114,7 +114,13 @@ fn bench_rustpy_code(group: &mut BenchmarkGroup, bench: &MicroBenchmar settings.dont_write_bytecode = true; settings.no_user_site = true; - Interpreter::new(settings, InitParameter::External).enter(|vm| { + Interpreter::new_with_init(settings, |vm| { + for (name, init) in rustpython_stdlib::get_module_inits().into_iter() { + vm.add_native_module(name, init); + } + InitParameter::External + }) + .enter(|vm| { let setup_code = vm .compile(&bench.setup, Mode::Exec, bench.name.to_owned()) .expect("Error compiling setup code");