增加测试用例

This commit is contained in:
刘祥超
2024-04-17 17:18:11 +08:00
parent 3e183ac824
commit 3ce30e36bb

View File

@@ -1,6 +1,7 @@
package ttlcache package ttlcache
import ( import (
"github.com/cespare/xxhash/v2"
"runtime" "runtime"
"testing" "testing"
) )
@@ -11,3 +12,10 @@ func BenchmarkHashKey(b *testing.B) {
HashKey([]byte("HELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLD")) HashKey([]byte("HELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLD"))
} }
} }
func BenchmarkHashKey2(b *testing.B) {
runtime.GOMAXPROCS(1)
for i := 0; i < b.N; i++ {
xxhash.Sum64String("HELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLD")
}
}