企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 概述 字符串转为整数 性能 ``` func BenchmarkMD5(b *testing.B) { for i := 0; i < b.N; i++ { md5Hash() } } func BenchmarkSHA1(b *testing.B) { for i := 0; i < b.N; i++ { sha1Hash() } } func BenchmarkMurmurHash32(b *testing.B) { for i := 0; i < b.N; i++ { murmur32() } } func BenchmarkMurmurHash64(b *testing.B) { for i := 0; i < b.N; i++ { murmur64() } } ``` ``` BenchmarkMD5-4 10000000 180 ns/op BenchmarkSHA1-4 10000000 211 ns/op BenchmarkMurmurHash32-4 50000000 25.7 ns/op BenchmarkMurmurHash64-4 20000000 66.2 ns/op ``` 用murmurhash要比md5和sha1都要好 ## 实例 ``` fmt.Println(murmur3.Sum32([]byte("123"))) //2662625771 fmt.Println(murmur3.Sum64([]byte("123"))) //10978418110857903978 ```