diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 10:19:20 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 10:30:39 +0300 |
commit | 4ce08ed50fba1981cd097665fdd6cffc3f87d8f5 (patch) | |
tree | 54eacfad31b7c9b5c05e1f5e05bad12b8250eb65 /internal/redirects | |
parent | ac23f02465369644c7d835a667e2c034fc629c37 (diff) |
test: fix benchmarks
Diffstat (limited to 'internal/redirects')
-rw-r--r-- | internal/redirects/redirects_benchmark_test.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/redirects/redirects_benchmark_test.go b/internal/redirects/redirects_benchmark_test.go index be86eb0c..d1c16a1c 100644 --- a/internal/redirects/redirects_benchmark_test.go +++ b/internal/redirects/redirects_benchmark_test.go @@ -3,6 +3,7 @@ package redirects import ( "context" "net/url" + "os" "path" "strings" "testing" @@ -29,7 +30,7 @@ func generateRedirectsFile(dirPath string, count int) error { func benchmarkRedirectsRewrite(b *testing.B, redirectsCount int) { ctx := context.Background() - root, tmpDir := testhelpers.TmpDir(nil, "ParseRedirects_benchmarks") + root, tmpDir := testhelpers.TmpDir(b, "ParseRedirects_benchmarks") err := generateRedirectsFile(tmpDir, redirectsCount) require.NoError(b, err) @@ -49,7 +50,7 @@ func benchmarkRedirectsRewrite(b *testing.B, redirectsCount int) { func BenchmarkRedirectsRewrite_withoutPlaceholders(b *testing.B) { b.Run("10 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 10) }) b.Run("100 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 100) }) - b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 1000) }) + b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 998) }) } func BenchmarkRedirectsRewrite_PlaceholdersEnabled(b *testing.B) { @@ -57,13 +58,13 @@ func BenchmarkRedirectsRewrite_PlaceholdersEnabled(b *testing.B) { b.Run("10 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 10) }) b.Run("100 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 100) }) - b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 1000) }) + b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 998) }) } func benchmarkRedirectsParseRedirects(b *testing.B, redirectsCount int) { ctx := context.Background() - root, tmpDir := testhelpers.TmpDir(nil, "ParseRedirects_benchmarks") + root, tmpDir := testhelpers.TmpDir(b, "ParseRedirects_benchmarks") err := generateRedirectsFile(tmpDir, redirectsCount) require.NoError(b, err) @@ -77,5 +78,5 @@ func benchmarkRedirectsParseRedirects(b *testing.B, redirectsCount int) { func BenchmarkRedirectsParseRedirects(b *testing.B) { b.Run("10 redirects", func(b *testing.B) { benchmarkRedirectsParseRedirects(b, 10) }) b.Run("100 redirects", func(b *testing.B) { benchmarkRedirectsParseRedirects(b, 100) }) - b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsParseRedirects(b, 1000) }) + b.Run("1000 redirects", func(b *testing.B) { benchmarkRedirectsParseRedirects(b, 998) }) } |