From 8a278a34854c598fbe9fc1c992b867791e80c00d Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 25 Jan 2024 16:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=8B=E7=BC=A9=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/compressions/writer_gzip_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/compressions/writer_gzip_test.go b/internal/compressions/writer_gzip_test.go index 71bc90f..b5d0338 100644 --- a/internal/compressions/writer_gzip_test.go +++ b/internal/compressions/writer_gzip_test.go @@ -5,12 +5,15 @@ package compressions_test import ( "bytes" "github.com/TeaOSLab/EdgeNode/internal/compressions" - "strings" "testing" ) func BenchmarkGzipWriter_Write(b *testing.B) { - var data = []byte(strings.Repeat("A", 1024)) + var data = make([]byte, 1024) + for i := 0; i < 1024; i++ { + data[i] = 'A' + byte(i%26) + } + b.ResetTimer() for i := 0; i < b.N; i++ { var buf = &bytes.Buffer{} @@ -36,7 +39,12 @@ func BenchmarkGzipWriter_Write(b *testing.B) { } func BenchmarkGzipWriter_Write_Parallel(b *testing.B) { - var data = []byte(strings.Repeat("A", 1024)) + var data = make([]byte, 1024) + for i := 0; i < 1024; i++ { + data[i] = 'A' + byte(i%26) + } + + b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() {