Skip to content

Commit

Permalink
Add a becnhmark for progressbar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed May 18, 2024
1 parent 61c2a43 commit a548192
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion widget/progressbar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var globalProgressRenderer fyne.WidgetRenderer

func BenchmarkProgressbar(b *testing.B) {
func BenchmarkProgressbarCreateRenderer(b *testing.B) {
var renderer fyne.WidgetRenderer
widget := &ProgressBar{}
b.ReportAllocs()
Expand All @@ -25,6 +25,17 @@ func BenchmarkProgressbar(b *testing.B) {
globalProgressRenderer = renderer
}

func BenchmarkProgressBarLayout(b *testing.B) {
b.ReportAllocs() // We should see zero allocations.

bar := &ProgressBar{}
renderer := bar.CreateRenderer()

for i := 0; i < b.N; i++ {
renderer.Layout(fyne.NewSize(100, 100))
}
}

func TestNewProgressBarWithData(t *testing.T) {
val := binding.NewFloat()
val.Set(0.4)
Expand Down

0 comments on commit a548192

Please sign in to comment.