Skip to content

Commit

Permalink
Added a benchmark for set iter
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Sep 8, 2020
1 parent b2ba83a commit c54b35f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions benches/bench_set.rs
@@ -0,0 +1,21 @@
#![feature(test)]

extern crate test;
use pyo3::prelude::*;
use pyo3::types::PySet;
use test::Bencher;

#[bench]
fn iter_set(b: &mut Bencher) {
let gil = Python::acquire_gil();
let py = gil.python();
const LEN: usize = 100_000;
let set = PySet::new(py, &(0..LEN).collect::<Vec<_>>()).unwrap();
let mut sum = 0;
b.iter(|| {
for x in set.iter() {
let i: u64 = x.extract().unwrap();
sum += i;
}
});
}

0 comments on commit c54b35f

Please sign in to comment.