github.com/gogf/gf/v2@v2.7.4/encoding/ghash/ghash_z_bench_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 // go test *.go -bench=".*" 8 9 package ghash_test 10 11 import ( 12 "testing" 13 14 "github.com/gogf/gf/v2/encoding/ghash" 15 ) 16 17 var ( 18 str = []byte("This is the test string for hash.") 19 ) 20 21 func Benchmark_BKDR(b *testing.B) { 22 for i := 0; i < b.N; i++ { 23 ghash.BKDR(str) 24 } 25 } 26 27 func Benchmark_BKDR64(b *testing.B) { 28 for i := 0; i < b.N; i++ { 29 ghash.BKDR64(str) 30 } 31 } 32 33 func Benchmark_SDBM(b *testing.B) { 34 for i := 0; i < b.N; i++ { 35 ghash.SDBM(str) 36 } 37 } 38 39 func Benchmark_SDBM64(b *testing.B) { 40 for i := 0; i < b.N; i++ { 41 ghash.SDBM64(str) 42 } 43 } 44 45 func Benchmark_RS(b *testing.B) { 46 for i := 0; i < b.N; i++ { 47 ghash.RS(str) 48 } 49 } 50 51 func Benchmark_RS64(b *testing.B) { 52 for i := 0; i < b.N; i++ { 53 ghash.RS64(str) 54 } 55 } 56 57 func Benchmark_JS(b *testing.B) { 58 for i := 0; i < b.N; i++ { 59 ghash.JS(str) 60 } 61 } 62 63 func Benchmark_JS64(b *testing.B) { 64 for i := 0; i < b.N; i++ { 65 ghash.JS64(str) 66 } 67 } 68 69 func Benchmark_PJW(b *testing.B) { 70 for i := 0; i < b.N; i++ { 71 ghash.PJW(str) 72 } 73 } 74 75 func Benchmark_PJW64(b *testing.B) { 76 for i := 0; i < b.N; i++ { 77 ghash.PJW64(str) 78 } 79 } 80 81 func Benchmark_ELF(b *testing.B) { 82 for i := 0; i < b.N; i++ { 83 ghash.ELF(str) 84 } 85 } 86 87 func Benchmark_ELF64(b *testing.B) { 88 for i := 0; i < b.N; i++ { 89 ghash.ELF64(str) 90 } 91 } 92 93 func Benchmark_DJB(b *testing.B) { 94 for i := 0; i < b.N; i++ { 95 ghash.DJB(str) 96 } 97 } 98 99 func Benchmark_DJB64(b *testing.B) { 100 for i := 0; i < b.N; i++ { 101 ghash.DJB64(str) 102 } 103 } 104 105 func Benchmark_AP(b *testing.B) { 106 for i := 0; i < b.N; i++ { 107 ghash.AP(str) 108 } 109 } 110 111 func Benchmark_AP64(b *testing.B) { 112 for i := 0; i < b.N; i++ { 113 ghash.AP64(str) 114 } 115 }