package ce
import (
"crypto/md5"
"math/rand"
)
func getmd5(s []byte) []byte {
md := md5.New()
md.Write(s)
x := md.Sum([]byte(""))
return x
}
func T() string {
name := rangdom_string()
x := getmd5(name)
if x[0] > 127 {
return "A"
} else {
return "B"
}
}
func rangdom_string() []byte {
var x []byte
for i := 0; i < 10; i++ {
a := rand.Intn(100)
x = append(x, byte(a+33))
}
return x
}
测试文件必须是*_test.go结尾
package ce
import "testing"
func Test_getmd5(t *testing.T) {
for i := 0; i < 1000000; i++ {
T()
}
}
func Benchmark_getmd5(b *testing.B) {
for i := 0; i < b.N; i++ {
T()
}
}
func Test_Range(t *testing.T) {
for i := 0; i < 1000000; i++ {
rangdom_string()
}
}