gf/g/encoding/ghash/ghash_test.go

115 lines
2.1 KiB
Go
Raw Normal View History

2018-02-24 17:24:12 +08:00
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
// go test *.go -bench=".*"
package ghash_test
import (
"gitee.com/johng/gf/g/encoding/ghash"
"testing"
)
var (
str = []byte("This is the test string for hash.")
2018-02-24 17:24:12 +08:00
)
func BenchmarkBKDRHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.BKDRHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkBKDRHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.BKDRHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkSDBMHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.SDBMHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkSDBMHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.SDBMHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkRSHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.RSHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkSRSHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.RSHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkJSHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.JSHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkJSHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.JSHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkPJWHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.PJWHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkPJWHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.PJWHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkELFHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.ELFHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkELFHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.ELFHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkDJBHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.DJBHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkDJBHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.DJBHash64(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkAPHash(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.APHash(str)
2018-02-24 17:24:12 +08:00
}
}
func BenchmarkAPHash64(b *testing.B) {
for i := 0; i < b.N; i++ {
ghash.APHash64(str)
2018-02-24 17:24:12 +08:00
}
}