Skip to content

Conversation

@vastonus
Copy link

These changes use b.Loop() to simplify the code and improve performance

Supported by Go Team, more info: https://go.dev/blog/testing-b-loop

More info can see https://go.dev/issue/73137.

Before this change:

 go test -run=^$ -bench=. ./internal/view -timeout=1h  
goos: darwin
goarch: arm64
pkg: github.com/derailed/k9s/internal/view
cpu: Apple M4
BenchmarkLogIndicatorRefresh-10    	  737971	      1556 ns/op	    1253 B/op	       6 allocs/op
BenchmarkLogFlush-10               	 2252066	       533.0 ns/op	     318 B/op	       0 allocs/op
PASS
ok  	github.com/derailed/k9s/internal/view	3.757s

after:

 go test -run=^$ -bench=. ./internal/view -timeout=1h  
goos: darwin
goarch: arm64
pkg: github.com/derailed/k9s/internal/view
cpu: Apple M4
BenchmarkLogIndicatorRefresh-10    	  722742	      1552 ns/op	    1252 B/op	       6 allocs/op
BenchmarkLogFlush-10               	 2277140	       525.9 ns/op	     317 B/op	       0 allocs/op
PASS
ok  	github.com/derailed/k9s/internal/view	3.179s

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vastonus Nice! Thank you for this update.
Should we also update the other benchmark tests?

@vastonus
Copy link
Author

@vastonus Nice! Thank you for this update. Should we also update the other benchmark tests?

Thank you for your reply. I’m organizing the information right now, and I’ll submit it again later.

@vastonus
Copy link
Author

@vastonus Nice! Thank you for this update. Should we also update the other benchmark tests?

@derailed Thanks for your patience.

I have found all the replacements; please review.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants