mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
io/router: improve areaOp methods performance
name old time/op new time/op delta AreaOp_Decode-8 10.5ns ± 2% 6.2ns ± 3% -41.50% (p=0.000 n=10+10) AreaOp_Hit-8 4.44ns ± 4% 3.57ns ± 2% -19.59% (p=0.000 n=10+10) Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
@@ -651,3 +651,22 @@ func BenchmarkRouterAdd(b *testing.B) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var benchAreaOp areaOp
|
||||
|
||||
func BenchmarkAreaOp_Decode(b *testing.B) {
|
||||
ops := new(op.Ops)
|
||||
pointer.Rect(image.Rectangle{Max: image.Pt(100, 100)}).Add(ops)
|
||||
for i := 0; i < b.N; i++ {
|
||||
benchAreaOp.Decode(ops.Data())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAreaOp_Hit(b *testing.B) {
|
||||
ops := new(op.Ops)
|
||||
pointer.Rect(image.Rectangle{Max: image.Pt(100, 100)}).Add(ops)
|
||||
benchAreaOp.Decode(ops.Data())
|
||||
for i := 0; i < b.N; i++ {
|
||||
benchAreaOp.Hit(f32.Pt(50, 50))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user