forked from joejulian/gio
6bf5d4dc2d
By keeping all the information in a single map, we avoid multiple lookups and can switch between frames more easily. Before ~35us, after ~20us for adding 50 new+old and switching the frame. Signed-off-by: Egon Elbre <egonelbre@gmail.com>
25 lines
418 B
Go
25 lines
418 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package gpu
|
|
|
|
import "testing"
|
|
|
|
func BenchmarkResourceCache(b *testing.B) {
|
|
offset := 0
|
|
const N = 100
|
|
|
|
cache := newResourceCache()
|
|
for i := 0; i < b.N; i++ {
|
|
// half are the same and half updated
|
|
for k := 0; k < N; k++ {
|
|
cache.put(offset+k, nullResource{})
|
|
}
|
|
cache.frame()
|
|
offset += N / 2
|
|
}
|
|
}
|
|
|
|
type nullResource struct{}
|
|
|
|
func (nullResource) release() {}
|