mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-08 03:00:27 +08:00
优化压缩相关测试用例
This commit is contained in:
@@ -5,12 +5,15 @@ package compressions_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/compressions"
|
"github.com/TeaOSLab/EdgeNode/internal/compressions"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkGzipWriter_Write(b *testing.B) {
|
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++ {
|
for i := 0; i < b.N; i++ {
|
||||||
var buf = &bytes.Buffer{}
|
var buf = &bytes.Buffer{}
|
||||||
@@ -36,7 +39,12 @@ func BenchmarkGzipWriter_Write(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkGzipWriter_Write_Parallel(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) {
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
for pb.Next() {
|
for pb.Next() {
|
||||||
|
|||||||
Reference in New Issue
Block a user