2023-08-29 06:26:36 +00:00
|
|
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
2020-04-07 19:37:02 +00:00
|
|
|
|
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
2022-03-23 07:07:28 +00:00
|
|
|
fn drop_many_objects(b: &mut Bencher<'_>) {
|
2022-07-19 17:34:23 +00:00
|
|
|
Python::with_gil(|py| {
|
|
|
|
b.iter(|| {
|
|
|
|
for _ in 0..1000 {
|
2023-11-16 15:41:58 +00:00
|
|
|
std::mem::drop(PyObject::from(py.None()));
|
2022-07-19 17:34:23 +00:00
|
|
|
}
|
|
|
|
});
|
2020-04-07 19:37:02 +00:00
|
|
|
});
|
|
|
|
}
|
2021-05-26 06:25:00 +00:00
|
|
|
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
|
|
c.bench_function("drop_many_objects", drop_many_objects);
|
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
|
|
criterion_main!(benches);
|