mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
827e20d84d
name old time/op new time/op delta Packer-32 559µs ± 2% 295µs ± 1% -47.18% (p=0.008 n=5+5) Signed-off-by: Egon Elbre <egonelbre@gmail.com>
31 lines
462 B
Go
31 lines
462 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package gpu
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkPacker(b *testing.B) {
|
|
var p packer
|
|
p.maxDims = image.Point{X: 4096, Y: 4096}
|
|
for i := 0; i < b.N; i++ {
|
|
p.clear()
|
|
p.newPage()
|
|
for k := 0; k < 500; k++ {
|
|
_, ok := p.tryAdd(xy(k))
|
|
if !ok {
|
|
b.Fatal("add failed", i, k, xy(k))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func xy(v int) image.Point {
|
|
return image.Point{
|
|
X: ((v / 16) % 16) + 8,
|
|
Y: (v % 16) + 8,
|
|
}
|
|
}
|