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

Function extract_array_like_1

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

Source from the content-addressed store, hash-verified

9};
10
11fn extract_array_like_1(c: &mut Criterion) {
12 const SIZES: &[usize] = &[2_usize.pow(5), 2_usize.pow(10), 2_usize.pow(15)];
13
14 let mut group = c.benchmark_group("extract_array_like_1");
15 for &size in SIZES {
16 Python::attach(|py| {
17 let locals = PyDict::new(py);
18 locals.set_item("size", size).unwrap();
19
20 let list = py
21 .eval(
22 c_str!("[float(i) for i in range(size)]"),
23 Some(&locals),
24 None,
25 )
26 .unwrap();
27
28 group.throughput(Throughput::Elements(size as u64));
29 group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _size| {
30 b.iter(|| {
31 let list = black_box(&list);
32
33 let _array: PyArrayLike1<'_, f64> = black_box(list.extract().unwrap());
34 });
35 });
36 });
37 }
38}
39
40fn extract_array_like_2(c: &mut Criterion) {
41 const SIZES: &[usize] = &[2_usize.pow(3), 2_usize.pow(5), 2_usize.pow(8)];

Callers

nothing calls this directly

Calls 1

extractMethod · 0.45

Tested by

no test coverage detected