// new random bin generator based on benchmark specs
348083
func getBin(xr *XorRand) *as.Bin {
	var bin *as.Bin
	switch binDataType {
	case "B":
		bin = &as.Bin{Name: "B", Value: getRandValue(xr)}
	case "S":
		bin = &as.Bin{Name: "S", Value: getRandValue(xr)}
	default:
		bin = &as.Bin{Name: "I", Value: getRandValue(xr)}
	}

	return bin
}
1214366
func randomSource() *rand.Rand {
	bytes := make([]byte, 8)
	seed := time.Now().UnixNano()
	if _, err := crand.Read(bytes); err == nil {
		seed = int64(binary.LittleEndian.Uint64(bytes))
	}

	src := rand.NewSource(seed)
	return rand.New(src)
}
174776
func binOpAdd(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpAdd, numOutputs, x, y)
}
596175
func (as ArraySpec) Rand() Input {
	return as.proc(func(i Input) Input {
		return i.Rand()
	})
}
478655
func generateVerbatim(p *parser, out *bytes.Buffer, data []byte, offset int) int {
	return generator(p, out, data, offset, '=', false, p.r.CodeSpan)
}
1011473
func Random(min, max int) int {
	if min == max {
		return min
	}
	if max < min {
		panic("max cannot be less than min")
	}
	rand.Seed(time.Now().UTC().UnixNano())
	return rand.Intn(max-min+1) + min
}
1358568
func NewRandom(s sd.Endpointer, seed int64) Balancer {
	return &random{
		s: s,
		r: rand.New(rand.NewSource(seed)),
	}
}
1002027
func GetRandomIndices(indiceCount, highestIndex int) []int {
	if highestIndex+1 < indiceCount {
		return nil
	}

	indices := make([]int, 0)
	if highestIndex+1 == indiceCount {
		for i := 0; i < indiceCount; i++ {
			indices = append(indices, i)
		}
		return indices
	}

	for len(indices) < indiceCount {
		n := RandomInt(highestIndex + 1)
		if IndexInSlice(indices, n, numbericEqual) != -1 {
			continue
		}
		indices = append(indices, n)
	}
	return indices
}
433725
func newRandomReader(r *rand.Rand) *randomReader {
	return &randomReader{b: &bytes.Buffer{}, r: r}
}
289501
func Generate() string {
	rand.Seed(time.Now().UTC().UnixNano())

	data := make([]int, 9)
	for i := 0; i < 9; i++ {
		data[i] = rand.Intn(9)
	}
	checkDigit1 := computeCheckDigit(data)
	data = append(data, checkDigit1)
	checkDigit2 := computeCheckDigit(data)
	data = append(data, checkDigit2)

	var cpf string
	for _, value := range data {
		cpf += strconv.Itoa(value)
	}
	return cpf
}
394950
func runBattery(ctx context.Context, st storage.Store, name string, chanSize, bulkSize int, f func(context.Context, storage.Store, int, int) ([]*runtime.BenchEntry, error)) int {
	// Add triples.
	fmt.Printf("Creating %s triples benchmark... ", name)
	bes, err := f(ctx, st, chanSize, bulkSize)
	if err != nil {
		log.Printf("[ERROR] %v\n", err)
		return 2
	}
	fmt.Printf("%d entries created\n", len(bes))

	fmt.Printf("Run %s benchmark sequentially... ", name)
	ts := time.Now()
	brs := runtime.RunBenchmarkBatterySequentially(bes)
	ds := time.Now().Sub(ts)
	fmt.Printf("(%v) done\n", ds)

	fmt.Printf("Run %s benchmark concurrently... ", name)
	tc := time.Now()
	brc := runtime.RunBenchmarkBatteryConcurrently(bes)
	dc := time.Now().Sub(tc)
	fmt.Printf("(%v) done\n\n", dc)

	format := func(br *runtime.BenchResult) string {
		if br.Err != nil {
			return fmt.Sprintf("%20s - %20s -[ERROR] %v", br.BatteryID, br.ID, br.Err)
		}
		tps := float64(br.Triples) / (float64(br.Mean) / float64(time.Second))
		return fmt.Sprintf("%20s - %20s - %05.2f triples/sec - %v/%v", br.BatteryID, br.ID, tps, br.Mean, br.StdDev)
	}

	sortAndPrint := func(ss []string) {
		sort.Strings(ss)
		for _, s := range ss {
			fmt.Println(s)
		}
	}

	fmt.Printf("Stats for sequentially run %s benchmark\n", name)
	var ress []string
	for _, br := range brs {
		ress = append(ress, format(br))
	}
	sortAndPrint(ress)
	fmt.Println()

	fmt.Printf("Stats for concurrently run %s benchmark\n", name)
	var resc []string
	for _, br := range brc {
		resc = append(resc, format(br))
	}
	sortAndPrint(resc)
	fmt.Println()

	return 0
}
915437
func CreateRandBytes(size uint32) ([]byte, error) {
	bytes := make([]byte, size)
	if _, err := rand.Read(bytes); err != nil {
		return nil, err
	}
	return bytes, nil
}
1243264
func (o Object) GenerateExample(r *RandomGenerator, seen []string) interface{} {
	// ensure fixed ordering
	keys := make([]string, 0, len(o))
	for n := range o {
		keys = append(keys, n)
	}
	sort.Strings(keys)

	res := make(map[string]interface{})
	for _, n := range keys {
		att := o[n]
		res[n] = att.Type.GenerateExample(r, seen)
	}
	return res
}
1249903
func RandomBuiltinFunc() string {
	d := orm.NewOrm().Driver()
	if d.Type() == orm.DR_Oracle {
		return "dbms_random.value(1,100000)"
	} else if d.Type() == orm.DR_MySQL {
		return "RAND()"
	} else {
		return "RANDOM()"
	}
}
554087
func random_data(size int) (b []byte) {
	b = make([]byte, size)
	rand.Read(b)
	return
}
287166
func NewIDGenerator() *IDGenerator {
	g := new(IDGenerator)
	_, err := rand.Read(g.seed[:])
	if err != nil {
		panic(err)
	}
	return g
}
627089
func GetRand() (*amcl.RAND, error) {
	seedLength := 32
	b := make([]byte, seedLength)
	_, err := rand.Read(b)
	if err != nil {
		return nil, errors.Wrap(err, "error getting randomness for seed")
	}
	rng := amcl.NewRAND()
	rng.Clean()
	rng.Seed(seedLength, b)
	return rng, nil
}