采用更快的Hash算法

This commit is contained in:
GoEdgeLab
2020-11-21 22:29:57 +08:00
parent 5485a5f663
commit d77749b0cd
12 changed files with 40 additions and 35 deletions

View File

@@ -3,7 +3,7 @@ package waf
import (
"bytes"
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/dchest/siphash"
"github.com/cespare/xxhash"
"github.com/iwind/TeaGo/assert"
"net/http"
"regexp"
@@ -174,7 +174,9 @@ func BenchmarkRuleSet_MatchRequest_Regexp3(b *testing.B) {
}
func BenchmarkHash(b *testing.B) {
runtime.GOMAXPROCS(1)
for i := 0; i < b.N; i++ {
_ = siphash.Hash(0, 0, bytes.Repeat([]byte("HELLO"), 10240))
_ = xxhash.Sum64(bytes.Repeat([]byte("HELLO"), 10240))
}
}