Merge pull request #1655 from davidhewitt/bench-tuple-new

bench_tuple: add benchmark for `PyTuple::new`
This commit is contained in:
David Hewitt 2021-06-05 09:27:40 +01:00 committed by GitHub
commit b3d3be600b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -17,6 +17,13 @@ fn iter_tuple(b: &mut Bencher) {
});
}
fn tuple_new(b: &mut Bencher) {
let gil = Python::acquire_gil();
let py = gil.python();
const LEN: usize = 50_000;
b.iter(|| PyTuple::new(py, 0..LEN));
}
fn tuple_get_item(b: &mut Bencher) {
let gil = Python::acquire_gil();
let py = gil.python();
@ -32,6 +39,7 @@ fn tuple_get_item(b: &mut Bencher) {
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("iter_tuple", iter_tuple);
c.bench_function("tuple_new", tuple_new);
c.bench_function("tuple_get_item", tuple_get_item);
}