@@ -51,9 +51,18 @@ fn values() -> Buffer<u32> {
5151 Buffer :: from ( values)
5252}
5353
54+ /// One value in ten null, at random, so almost every chunk of 64 values has a null.
55+ fn sparse_nulls ( ) -> Validity {
56+ let mut rng = Rng ( 0xD1B5_4A32_D192_ED03 ) ;
57+ Validity :: from ( BitBuffer :: from_iter (
58+ ( 0 ..LEN ) . map ( |_| !rng. next ( ) . is_multiple_of ( 10 ) ) ,
59+ ) )
60+ }
61+
5462/// Computes the statistics of a fresh array each iteration, so that the bounds cached on the array
55- /// by a previous iteration are not reused.
56- fn bench_stats ( bencher : Bencher , validity : Validity ) {
63+ /// by a previous iteration are not reused. With `count_distinct_values`, every statistic is
64+ /// computed, as when a dictionary scheme is enabled.
65+ fn bench_stats ( bencher : Bencher , validity : Validity , count_distinct_values : bool ) {
5766 let values = values ( ) ;
5867 bencher
5968 . with_inputs ( || {
@@ -66,7 +75,7 @@ fn bench_stats(bencher: Bencher, validity: Validity) {
6675 IntegerStats :: generate_opts (
6776 array,
6877 GenerateStatsOptions {
69- count_distinct_values : false ,
78+ count_distinct_values,
7079 } ,
7180 ctx,
7281 )
@@ -75,13 +84,20 @@ fn bench_stats(bencher: Bencher, validity: Validity) {
7584
7685#[ divan:: bench]
7786fn integer_stats_non_null ( bencher : Bencher ) {
78- bench_stats ( bencher, Validity :: NonNullable ) ;
87+ bench_stats ( bencher, Validity :: NonNullable , false ) ;
7988}
8089
81- /// One value in ten is null, at random, so almost every chunk of 64 values has a null.
8290#[ divan:: bench]
8391fn integer_stats_nullable ( bencher : Bencher ) {
84- let mut rng = Rng ( 0xD1B5_4A32_D192_ED03 ) ;
85- let valid = BitBuffer :: from_iter ( ( 0 ..LEN ) . map ( |_| !rng. next ( ) . is_multiple_of ( 10 ) ) ) ;
86- bench_stats ( bencher, Validity :: from ( valid) ) ;
92+ bench_stats ( bencher, sparse_nulls ( ) , false ) ;
93+ }
94+
95+ #[ divan:: bench]
96+ fn integer_stats_all_non_null ( bencher : Bencher ) {
97+ bench_stats ( bencher, Validity :: NonNullable , true ) ;
98+ }
99+
100+ #[ divan:: bench]
101+ fn integer_stats_all_nullable ( bencher : Bencher ) {
102+ bench_stats ( bencher, sparse_nulls ( ) , true ) ;
87103}
0 commit comments