github.com/Seikaijyu/gio@v0.0.1/gpu/caches_test.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package gpu
     4  
     5  import "testing"
     6  
     7  func BenchmarkResourceCache(b *testing.B) {
     8  	offset := 0
     9  	const N = 100
    10  
    11  	cache := newResourceCache()
    12  	for i := 0; i < b.N; i++ {
    13  		// half are the same and half updated
    14  		for k := 0; k < N; k++ {
    15  			cache.put(offset+k, nullResource{})
    16  		}
    17  		cache.frame()
    18  		offset += N / 2
    19  	}
    20  }
    21  
    22  type nullResource struct{}
    23  
    24  func (nullResource) release() {}