File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ serde_json = { workspace = true }
9696serde_test = { workspace = true }
9797vortex-array = { path = " ." , features = [" _test-harness" , " table-display" ] }
9898
99+ [[bench ]]
100+ name = " cast_primitive"
101+ harness = false
102+
99103[[bench ]]
100104name = " search_sorted"
101105harness = false
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ // SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+ use divan:: Bencher ;
5+ use rand:: prelude:: * ;
6+ use vortex_array:: IntoArray ;
7+ use vortex_array:: arrays:: PrimitiveArray ;
8+ use vortex_array:: builtins:: ArrayBuiltins ;
9+ use vortex_array:: dtype:: DType ;
10+ use vortex_array:: dtype:: Nullability ;
11+ use vortex_array:: dtype:: PType ;
12+
13+ fn main ( ) {
14+ divan:: main ( ) ;
15+ }
16+
17+ const N : usize = 100_000 ;
18+
19+ #[ divan:: bench]
20+ fn cast_u16_to_u32 ( bencher : Bencher ) {
21+ let mut rng = StdRng :: seed_from_u64 ( 42 ) ;
22+ #[ expect( clippy:: cast_possible_truncation) ]
23+ let arr = PrimitiveArray :: from_option_iter ( ( 0 ..N ) . map ( |i| {
24+ if rng. random_bool ( 0.5 ) {
25+ None
26+ } else {
27+ Some ( i as u16 )
28+ }
29+ } ) )
30+ . into_array ( ) ;
31+ bencher. with_inputs ( || arr. clone ( ) ) . bench_refs ( |a| {
32+ #[ expect( clippy:: unwrap_used) ]
33+ a. cast ( DType :: Primitive ( PType :: U32 , Nullability :: Nullable ) )
34+ . unwrap ( )
35+ . to_canonical ( )
36+ } ) ;
37+ }
You can’t perform that action at this time.
0 commit comments