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

Function extract_array_like_2

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

Source from the content-addressed store, hash-verified

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)];
42
43 let mut group = c.benchmark_group("extract_array_like_2");
44 for &size in SIZES {
45 Python::attach(|py| {
46 let locals = PyDict::new(py);
47 locals.set_item("size", size).unwrap();
48
49 let list = py
50 .eval(
51 c_str!("[[float(i + j) for i in range(size)] for j in range(size)]"),
52 Some(&locals),
53 None,
54 )
55 .unwrap();
56
57 group.throughput(Throughput::Elements(size.pow(2) as u64));
58 group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _size| {
59 b.iter(|| {
60 let list = black_box(&list);
61
62 let _array: PyArrayLike2<'_, f64> = black_box(list.extract().unwrap());
63 });
64 });
65 });
66 }
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)];

Callers

nothing calls this directly

Calls 1

extractMethod · 0.45

Tested by

no test coverage detected