mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
30 lines
470 B
Go
30 lines
470 B
Go
|
package logstorage
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync/atomic"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func BenchmarkHash128(b *testing.B) {
|
||
|
a := make([][]byte, 100)
|
||
|
for i := range a {
|
||
|
a[i] = []byte(fmt.Sprintf("some string %d", i))
|
||
|
}
|
||
|
b.ReportAllocs()
|
||
|
b.SetBytes(int64(len(a)))
|
||
|
b.RunParallel(func(pb *testing.PB) {
|
||
|
var n uint64
|
||
|
for pb.Next() {
|
||
|
for _, b := range a {
|
||
|
h := hash128(b)
|
||
|
n += h.hi
|
||
|
n += h.lo
|
||
|
}
|
||
|
}
|
||
|
atomic.AddUint64(&GlobalSinkU64, n)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
var GlobalSinkU64 uint64
|