Przeglądaj źródła

refactor(tests): use b.Loop() instead of for range b.N

See https://tip.golang.org/doc/go1.24#new-benchmark-function
jvoisin 1 rok temu
rodzic
commit
43546976d2

+ 1 - 1
internal/reader/parser/parser_test.go

@@ -22,7 +22,7 @@ func BenchmarkParse(b *testing.B) {
 		}
 		testCases[filename][1] = string(data)
 	}
-	for range b.N {
+	for b.Loop() {
 		for _, v := range testCases {
 			ParseFeed(v[0], strings.NewReader(v[1]))
 		}

+ 1 - 1
internal/reader/readingtime/readingtime_test.go

@@ -80,7 +80,7 @@ func TestEstimateReadingTime(t *testing.T) {
 }
 
 func BenchmarkEstimateReadingTime(b *testing.B) {
-	for range b.N {
+	for b.Loop() {
 		for _, sample := range samples {
 			EstimateReadingTime(sample, 200, 500)
 		}

+ 1 - 1
internal/reader/sanitizer/sanitizer_test.go

@@ -25,7 +25,7 @@ func BenchmarkSanitize(b *testing.B) {
 		}
 		testCases[filename][1] = string(data)
 	}
-	for range b.N {
+	for b.Loop() {
 		for _, v := range testCases {
 			SanitizeHTMLWithDefaultOptions(v[0], v[1])
 		}