package flow_test import ( "math/rand" "os" "strconv" "testing" "dev.hexasoftware.com/x/flow" ) var ( vecsize = 10 ) func init() { var err error vecsizeEnv := os.Getenv("VECSIZE") if vecsizeEnv != "" { vecsize, err = strconv.Atoi(vecsizeEnv) if err != nil { panic(err) } } } func BenchmarkMul(b *testing.B) { f := flow.New() v1 := f.Variable(randvec()) v2 := f.Variable(randvec()) mulop := f.Op("vecmul", v1, v2) for i := 0; i < b.N; i++ { f.Run(mulop) } } func randvec() []float32 { r := make([]float32, vecsize) for i := range r { r[i] = rand.Float32() } return r }