github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/testing/load/rand.go (about) 1 package load 2 3 import ( 4 "encoding/hex" 5 "math/rand" 6 ) 7 8 func newRand(seed int) *rand.Rand { 9 return rand.New(rand.NewSource(int64(seed))) 10 } 11 12 func randInt(r *rand.Rand, min, max int) int { 13 if max == min { 14 return max 15 } 16 return r.Intn(max-min) + min 17 } 18 19 func randString(r *rand.Rand, min, max int) string { 20 l := randInt(r, min, max) 21 buf := make([]byte, l) 22 r.Read(buf) 23 return hex.EncodeToString(buf) 24 }