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

Function from_slice

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

Source from the content-addressed store, hash-verified

80}
81
82fn from_slice(c: &mut Criterion) {
83 const SIZES: &[usize] = &[2_usize.pow(5), 2_usize.pow(10), 2_usize.pow(15)];
84
85 let mut group = c.benchmark_group("from_slice");
86 for &size in SIZES {
87 let vec = (0..size).collect::<Vec<_>>();
88
89 Python::attach(|py| {
90 group.throughput(Throughput::Elements(size as u64));
91 group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _size| {
92 b.iter(|| {
93 let slice = black_box(&vec[..]);
94 black_box(PyArray1::from_slice(py, slice));
95 });
96 });
97 });
98 }
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)];

Callers 8

from_object_sliceFunction · 0.85
test_hasobject_flagFunction · 0.85
to_pyarrayMethod · 0.85
convertFunction · 0.85
casting_worksFunction · 0.85
unbind_worksFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_hasobject_flagFunction · 0.68
casting_worksFunction · 0.68
unbind_worksFunction · 0.68