mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
apps/gophers: split main into App and UI and add BenchmarkUI
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gioui.org/ui"
|
||||
"gioui.org/ui/input"
|
||||
"gioui.org/ui/layout"
|
||||
)
|
||||
|
||||
type queue struct{}
|
||||
|
||||
type config struct{}
|
||||
|
||||
func BenchmarkUI(b *testing.B) {
|
||||
invalidate := func() {}
|
||||
fetch := func(_ string) {}
|
||||
u := newUI(invalidate, fetch)
|
||||
ops := new(ui.Ops)
|
||||
q := new(queue)
|
||||
c := new(config)
|
||||
cs := layout.RigidConstraints(image.Point{800, 600})
|
||||
for i := 0; i < b.N; i++ {
|
||||
ops.Reset()
|
||||
u.Layout(c, q, ops, cs)
|
||||
}
|
||||
}
|
||||
|
||||
func (queue) Next(k input.Key) (input.Event, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (config) Now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
func (config) Px(v ui.Value) int {
|
||||
return int(v.V + .5)
|
||||
}
|
||||
Reference in New Issue
Block a user