2020-11-21 21:43:03 +08:00
|
|
|
package ttlcache
|
2020-11-21 20:44:19 +08:00
|
|
|
|
|
|
|
|
import (
|
2024-04-17 17:18:11 +08:00
|
|
|
"github.com/cespare/xxhash/v2"
|
2020-11-21 20:44:19 +08:00
|
|
|
"runtime"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func BenchmarkHashKey(b *testing.B) {
|
|
|
|
|
runtime.GOMAXPROCS(1)
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
HashKey([]byte("HELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLD"))
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-17 17:18:11 +08:00
|
|
|
|
|
|
|
|
func BenchmarkHashKey2(b *testing.B) {
|
|
|
|
|
runtime.GOMAXPROCS(1)
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
xxhash.Sum64String("HELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLDHELLO,WORLD")
|
|
|
|
|
}
|
|
|
|
|
}
|