mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
modernize: Use b.Loop (introduced in Go 1.24)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
func BenchmarkGetTotalUsedFds(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
_ = GetTotalUsedFds(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ func BenchmarkWrite(b *testing.B) {
|
||||
data := []byte("Test line for testing stdwriter performance\n")
|
||||
data = bytes.Repeat(data, 100)
|
||||
b.SetBytes(int64(len(data)))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
for b.Loop() {
|
||||
if _, err := w.Write(data); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ func TestBytesPipeWriteRandomChunks(t *testing.T) {
|
||||
func BenchmarkBytesPipeWrite(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
testData := []byte("pretty short line, because why not?")
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
readBuf := make([]byte, 1024)
|
||||
buf := New()
|
||||
go func() {
|
||||
@@ -203,7 +203,7 @@ func BenchmarkBytesPipeWrite(b *testing.B) {
|
||||
func BenchmarkBytesPipeRead(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
rd := make([]byte, 512)
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
b.StopTimer()
|
||||
buf := New()
|
||||
for j := 0; j < 500; j++ {
|
||||
|
||||
@@ -145,8 +145,8 @@ func BenchmarkUnbuffered(b *testing.B) {
|
||||
buf.WriteString(testLine)
|
||||
testText := buf.Bytes()
|
||||
b.SetBytes(int64(5 * len(testText)))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
for b.Loop() {
|
||||
b.StopTimer()
|
||||
setUpWriter()
|
||||
b.StartTimer()
|
||||
|
||||
Reference in New Issue
Block a user