github.com/zhongdalu/gf@v1.0.0/g/util/grand/grand_z_bench_test.go (about) 1 // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). 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/zhongdalu/gf. 6 7 // go test *.go -bench=".*" 8 9 package grand_test 10 11 import ( 12 "github.com/zhongdalu/gf/g/util/grand" 13 "testing" 14 ) 15 16 var buffer = make([]byte, 8) 17 18 func Benchmark_Rand(b *testing.B) { 19 for i := 0; i < b.N; i++ { 20 grand.Rand(0, 999999999) 21 } 22 } 23 24 //func Benchmark_Buffer(b *testing.B) { 25 // for i := 0; i < b.N; i++ { 26 // if _, err := rand.Read(buffer); err == nil { 27 // binary.LittleEndian.Uint64(buffer) 28 // } 29 // } 30 //}