zeroshade commented on code in PR #1351:
URL: https://github.com/apache/arrow-go/pull/1351#discussion_r4188757974
##########
arrow/compute/boolean_cast_bench_test.go:
##########
@@ -82,3 +82,76 @@ func BenchmarkNumericToBoolCast(b *testing.B) {
}
}
}
+
+func BenchmarkNumericToBoolCastNullPatterns(b *testing.B) {
+ patterns := []struct {
+ name string
+ isNull func(i, size int) bool
+ }{
+ {name: "all-valid", isNull: func(int, int) bool { return false
}},
+ {name: "sparse-1pct", isNull: func(i, _ int) bool { return
i%100 == 0 }},
+ {name: "alternating-null", isNull: func(i, _ int) bool { return
i%2 == 0 }},
+ {name: "clustered50-null", isNull: func(i, _ int) bool { return
(i/4096)%2 == 0 }},
+ }
+
+ for _, typ := range []arrow.DataType{
+ arrow.PrimitiveTypes.Int32,
+ arrow.PrimitiveTypes.Uint32,
+ arrow.PrimitiveTypes.Int64,
+ arrow.PrimitiveTypes.Uint64,
+ arrow.PrimitiveTypes.Float32,
+ arrow.PrimitiveTypes.Float64,
+ } {
+ width := int64(typ.(arrow.FixedWidthDataType).Bytes())
+ for _, size := range []int{65536, 1_000_000} {
+ size := size
Review Comment:
Nit: `size := size` (and `pattern := pattern` at L109) aren't needed since
Go 1.22; `go.mod` is on 1.26.
##########
arrow/compute/boolean_cast_bench_test.go:
##########
@@ -82,3 +82,76 @@ func BenchmarkNumericToBoolCast(b *testing.B) {
}
}
}
+
+func BenchmarkNumericToBoolCastNullPatterns(b *testing.B) {
+ patterns := []struct {
+ name string
+ isNull func(i, size int) bool
+ }{
+ {name: "all-valid", isNull: func(int, int) bool { return false
}},
+ {name: "sparse-1pct", isNull: func(i, _ int) bool { return
i%100 == 0 }},
+ {name: "alternating-null", isNull: func(i, _ int) bool { return
i%2 == 0 }},
+ {name: "clustered50-null", isNull: func(i, _ int) bool { return
(i/4096)%2 == 0 }},
+ }
+
+ for _, typ := range []arrow.DataType{
+ arrow.PrimitiveTypes.Int32,
+ arrow.PrimitiveTypes.Uint32,
+ arrow.PrimitiveTypes.Int64,
+ arrow.PrimitiveTypes.Uint64,
+ arrow.PrimitiveTypes.Float32,
+ arrow.PrimitiveTypes.Float64,
+ } {
+ width := int64(typ.(arrow.FixedWidthDataType).Bytes())
+ for _, size := range []int{65536, 1_000_000} {
+ size := size
+ for _, pattern := range patterns {
+ pattern := pattern
+ b.Run(fmt.Sprintf("type=%s/size=%d/nulls=%s",
typ, size, pattern.name), func(b *testing.B) {
+ mem := memory.NewGoAllocator()
+ input :=
newBooleanCastBenchmarkArrayWithNullPattern(mem, typ, size, pattern.isNull)
+ defer input.Release()
+ opts := compute.DefaultCastOptions(true)
+ opts.ToType =
arrow.FixedWidthTypes.Boolean
+ ctx := context.Background()
+
+ b.ReportAllocs()
+ b.SetBytes(int64(size) * width)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
Review Comment:
Nit: use `for b.Loop()` and drop `b.ResetTimer()`, matching the rest of
`arrow/compute`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]