Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed May 18, 2024
1 parent 7a361cb commit b8b6b5c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions widget/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,29 @@ func TestList_RefreshUpdatesAllItems(t *testing.T) {
list.Refresh()
assert.Equal(t, "0.0.", printOut)
}

var minSize fyne.Size

func BenchmarkContentMinSize(b *testing.B) {
b.StopTimer()

l := NewList(
func() int { return 1000000 },
func() fyne.CanvasObject {
return NewLabel("Test")
},
func(id ListItemID, item fyne.CanvasObject) {
item.(*Label).SetText(fmt.Sprintf("%d", id))
},
)
l.SetItemHeight(10, 55)
l.SetItemHeight(12345, 2)

min := fyne.Size{}
b.StartTimer()
for i := 0; i < b.N; i++ {
min = l.contentMinSize()
}

minSize = min
}

0 comments on commit b8b6b5c

Please sign in to comment.