gioui.org@v0.6.1-0.20240506124620-7a9ce51988ce/gpu/pack_test.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package gpu
     4  
     5  import (
     6  	"image"
     7  	"testing"
     8  )
     9  
    10  func BenchmarkPacker(b *testing.B) {
    11  	var p packer
    12  	p.maxDims = image.Point{X: 4096, Y: 4096}
    13  	for i := 0; i < b.N; i++ {
    14  		p.clear()
    15  		p.newPage()
    16  		for k := 0; k < 500; k++ {
    17  			_, ok := p.tryAdd(xy(k))
    18  			if !ok {
    19  				b.Fatal("add failed", i, k, xy(k))
    20  			}
    21  		}
    22  	}
    23  }
    24  
    25  func xy(v int) image.Point {
    26  	return image.Point{
    27  		X: ((v / 16) % 16) + 8,
    28  		Y: (v % 16) + 8,
    29  	}
    30  }