Skip to content

Commit

Permalink
Adjust the GIL benchmark to the updated reference pool semantics.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Apr 21, 2024
1 parent 6d46508 commit c56282a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pyo3-benches/benches/bench_gil.rs
@@ -1,4 +1,4 @@
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Bencher, Criterion};
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};

use pyo3::prelude::*;

Expand All @@ -9,14 +9,8 @@ fn bench_clean_acquire_gil(b: &mut Bencher<'_>) {

fn bench_dirty_acquire_gil(b: &mut Bencher<'_>) {
let obj = Python::with_gil(|py| py.None());
b.iter_batched(
|| {
// Clone and drop an object so that the GILPool has work to do.
let _ = obj.clone();
},
|_| Python::with_gil(|_| {}),
BatchSize::NumBatches(1),
);
// Drop the returned clone of the object so that the reference pool has work to do.
b.iter(|| Python::with_gil(|py| obj.clone_ref(py)));
}

fn criterion_benchmark(c: &mut Criterion) {
Expand Down

0 comments on commit c56282a

Please sign in to comment.