MCPcopy Create free account
hub / github.com/PyO3/rust-numpy / extract_array_like_3

Function extract_array_like_3

benches/array_like.rs:69–96  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

67}
68
69fn extract_array_like_3(c: &mut Criterion) {
70 const SIZES: &[usize] = &[2_usize.pow(2), 2_usize.pow(4), 2_usize.pow(5)];
71
72 let mut group = c.benchmark_group("extract_array_like_3");
73 for &size in SIZES {
74 Python::attach(|py| {
75 let locals = PyDict::new(py);
76 locals.set_item("size", size).unwrap();
77
78 let list = py
79 .eval(
80 c_str!("[[[float(i + j + k) for i in range(size)] for j in range(size)] for k in range(size)]"),
81 Some(&locals),
82 None,
83 )
84 .unwrap();
85
86 group.throughput(Throughput::Elements(size.pow(3) as u64));
87 group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _size| {
88 b.iter(|| {
89 let list = black_box(&list);
90
91 let _array: PyArrayLike3<'_, f64> = black_box(list.extract().unwrap());
92 });
93 });
94 });
95 }
96}
97
98criterion_group!(
99 benches,

Callers

nothing calls this directly

Calls 1

extractMethod · 0.45

Tested by

no test coverage detected