You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

常用经典哈希函数Go语言实现,提供uint32uint64类型的哈希函数。

使用方式

import "github.com/gogf/gf/encoding/ghash"

接口文档

https://godoc.org/github.com/gogf/gf/encoding/ghash

基准测试:

goos: darwin
goarch: amd64
pkg: github.com/gogf/gf/v2/encoding/ghash
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark_BKDR
Benchmark_BKDR-12         	57771193	        19.26 ns/op
Benchmark_BKDR64
Benchmark_BKDR64-12       	48366402	        22.29 ns/op
Benchmark_BKDR64Str
Benchmark_BKDR64Str-12    	15489008	        76.86 ns/op
Benchmark_SDBM
Benchmark_SDBM-12         	62047813	        19.21 ns/op
Benchmark_SDBM64
Benchmark_SDBM64-12       	53550828	        22.53 ns/op
Benchmark_SDBM64Str
Benchmark_SDBM64Str-12    	14554824	        78.05 ns/op
Benchmark_RS
Benchmark_RS-12           	62434228	        19.22 ns/op
Benchmark_SRS64
Benchmark_SRS64-12        	53818828	        22.57 ns/op
Benchmark_SRS64Str
Benchmark_SRS64Str-12     	14620653	        77.53 ns/op
Benchmark_JS
Benchmark_JS-12           	63068625	        19.27 ns/op
Benchmark_JS64
Benchmark_JS64-12         	52787070	        22.57 ns/op
Benchmark_JS64Str
Benchmark_JS64Str-12      	15130551	        78.44 ns/op
Benchmark_PJW
Benchmark_PJW-12          	42726382	        28.05 ns/op
Benchmark_PJW64
Benchmark_PJW64-12        	31651485	        37.24 ns/op
Benchmark_PJW64Str
Benchmark_PJW64Str-12     	17988242	        66.14 ns/op
Benchmark_ELF
Benchmark_ELF-12          	38743060	        32.27 ns/op
Benchmark_ELF64
Benchmark_ELF64-12        	44347190	        27.21 ns/op
Benchmark_ELF64Str
Benchmark_ELF64Str-12     	21851034	        54.08 ns/op
Benchmark_DJB
Benchmark_DJB-12          	62567550	        19.19 ns/op
Benchmark_DJB64
Benchmark_DJB64-12        	48457785	        22.59 ns/op
Benchmark_DJB64Str
Benchmark_DJB64Str-12     	17026551	        70.00 ns/op
Benchmark_AP
Benchmark_AP-12           	29729103	        40.25 ns/op
Benchmark_AP64
Benchmark_AP64-12         	28342160	        42.93 ns/op
Benchmark_AP64Str
Benchmark_AP64Str-12      	13015425	        91.21 ns/op





  • No labels