func RunCommandLine() error { params.workload = strings.Replace(params.workload, " ", "", -1) workloadContext := NewContext() workloads.PopulateRestContext(params.restTarget, params.restUser, params.restPass, params.restSpace, workloadContext) workloads.PopulateAppContext(params.app, params.manifest, workloadContext) return WithConfiguredWorkerAndSlaves(func(worker benchmarker.Worker) error { return validateParameters(worker, func() error { return store.WithStore(func(store Store) error { parsedConcurrency, err := parseConcurrency(params.concurrency) if err != nil { return err } parsedConcurrencyStepTime := parseConcurrencyStepTime(params.concurrencyStepTime) lab := LaboratoryFactory(store) handlers := make([]func(<-chan *Sample), 0) if !params.silent { handlers = append(handlers, func(s <-chan *Sample) { display(params.concurrency, params.iterations, params.interval, params.stop, params.concurrencyStepTime, s) }) } exitBlocker := make(chan int) if params.silent { var tryBlock = func(s <-chan *Sample) { for _ = range s { exitBlocker <- 1 } close(exitBlocker) } handlers = append(handlers, func(s <-chan *Sample) { tryBlock(s) }) } lab.RunWithHandlers( NewRunnableExperiment( NewExperimentConfiguration( params.iterations, parsedConcurrency, parsedConcurrencyStepTime, params.interval, params.stop, worker, params.workload)), handlers, workloadContext) if params.silent { SilentExit(exitBlocker) } else { BlockExit() } return err }) }) }) }
func (ctx *serverContext) handlePush(w http.ResponseWriter, r *http.Request) (interface{}, error) { pushes, err := strconv.Atoi(r.FormValue("iterations")) if err != nil { pushes = 1 } concurrency := make([]int, 1) concurrency[0], err = strconv.Atoi(r.FormValue("concurrency")) if err != nil { concurrency[0] = 1 } rawConcurrencyStepTime, err := strconv.Atoi(r.FormValue("concurrency:timeBetweenSteps")) concurrencyStepTime := time.Duration(rawConcurrencyStepTime) * time.Second if err != nil { concurrencyStepTime = 60 * time.Second } interval, err := strconv.Atoi(r.FormValue("interval")) if err != nil { interval = 0 } stop, err := strconv.Atoi(r.FormValue("stop")) if err != nil { stop = 0 } workload := r.FormValue("workload") if workload == "" { workload = "cf:push" } workloadContext := context.New() workloadContext.PutString("app", r.FormValue("cfApp")) workloadContext.PutString("app:manifest", r.FormValue("cfManifest")) workloads.PopulateRestContext(r.FormValue("cfTarget"), r.FormValue("cfUsername"), r.FormValue("cfPassword"), r.FormValue("cfSpace"), workloadContext) experiment, _ := ctx.lab.Run( NewRunnableExperiment( NewExperimentConfiguration( pushes, concurrency, concurrencyStepTime, interval, stop, ctx.worker, workload)), workloadContext) return ctx.router.Get("experiment").URL("name", experiment) }