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

Function from_object_slice

benches/array.rs:101–120  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

99}
100
101fn from_object_slice(c: &mut Criterion) {
102 const SIZES: &[usize] = &[2_usize.pow(5), 2_usize.pow(10), 2_usize.pow(15)];
103
104 let mut group = c.benchmark_group("from_object_slice");
105 for &size in SIZES {
106 Python::attach(|py| {
107 let vec = (0..size)
108 .map(|val| val.into_py_any(py).unwrap())
109 .collect::<Vec<_>>();
110
111 group.throughput(Throughput::Elements(size as u64));
112 group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _size| {
113 b.iter(|| {
114 let slice = black_box(&vec[..]);
115 black_box(PyArray1::from_slice(py, slice));
116 });
117 });
118 });
119 }
120}
121
122fn from_vec2(c: &mut Criterion) {
123 const SIZES: &[usize] = &[2_usize.pow(3), 2_usize.pow(5), 2_usize.pow(8)];

Callers

nothing calls this directly

Calls 1

from_sliceFunction · 0.85

Tested by

no test coverage detected