update tuple benchmarks for bound API
This commit is contained in:
parent
674f7282d8
commit
57a49a2b12
|
@ -20,7 +20,7 @@ fn iter_list(b: &mut Bencher<'_>) {
|
||||||
fn list_new(b: &mut Bencher<'_>) {
|
fn list_new(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
b.iter(|| PyList::new_bound(py, 0..LEN));
|
b.iter_with_large_drop(|| PyList::new_bound(py, 0..LEN));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ use pyo3::types::{PyList, PySequence, PyTuple};
|
||||||
fn iter_tuple(b: &mut Bencher<'_>) {
|
fn iter_tuple(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 100_000;
|
const LEN: usize = 100_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN);
|
let tuple = PyTuple::new_bound(py, 0..LEN);
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for x in tuple {
|
for x in tuple.iter_borrowed() {
|
||||||
let i: u64 = x.extract().unwrap();
|
let i: u64 = x.extract().unwrap();
|
||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ fn iter_tuple(b: &mut Bencher<'_>) {
|
||||||
fn tuple_new(b: &mut Bencher<'_>) {
|
fn tuple_new(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
b.iter(|| PyTuple::new(py, 0..LEN));
|
b.iter_with_large_drop(|| PyTuple::new_bound(py, 0..LEN));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tuple_get_item(b: &mut Bencher<'_>) {
|
fn tuple_get_item(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN);
|
let tuple = PyTuple::new_bound(py, 0..LEN);
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for i in 0..LEN {
|
for i in 0..LEN {
|
||||||
|
@ -41,7 +41,7 @@ fn tuple_get_item(b: &mut Bencher<'_>) {
|
||||||
fn tuple_get_item_unchecked(b: &mut Bencher<'_>) {
|
fn tuple_get_item_unchecked(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN);
|
let tuple = PyTuple::new_bound(py, 0..LEN);
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for i in 0..LEN {
|
for i in 0..LEN {
|
||||||
|
@ -56,7 +56,7 @@ fn tuple_get_item_unchecked(b: &mut Bencher<'_>) {
|
||||||
fn sequence_from_tuple(b: &mut Bencher<'_>) {
|
fn sequence_from_tuple(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN).to_object(py);
|
let tuple = PyTuple::new_bound(py, 0..LEN).to_object(py);
|
||||||
b.iter(|| tuple.extract::<&PySequence>(py).unwrap());
|
b.iter(|| tuple.extract::<&PySequence>(py).unwrap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,22 +64,16 @@ fn sequence_from_tuple(b: &mut Bencher<'_>) {
|
||||||
fn tuple_new_list(b: &mut Bencher<'_>) {
|
fn tuple_new_list(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN);
|
let tuple = PyTuple::new_bound(py, 0..LEN);
|
||||||
b.iter(|| {
|
b.iter_with_large_drop(|| PyList::new_bound(py, tuple.iter_borrowed()));
|
||||||
let _pool = unsafe { py.new_pool() };
|
|
||||||
let _ = PyList::new(py, tuple);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tuple_to_list(b: &mut Bencher<'_>) {
|
fn tuple_to_list(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
const LEN: usize = 50_000;
|
const LEN: usize = 50_000;
|
||||||
let tuple = PyTuple::new(py, 0..LEN);
|
let tuple = PyTuple::new_bound(py, 0..LEN);
|
||||||
b.iter(|| {
|
b.iter_with_large_drop(|| tuple.to_list());
|
||||||
let _pool = unsafe { py.new_pool() };
|
|
||||||
let _ = tuple.to_list();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue