mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
gpu: optimize resourceCache
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>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// 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() {}
|
||||
Reference in New Issue
Block a user