Ejemplo n.º 1
0
func (ctx *context) handlePush(w http.ResponseWriter, r *http.Request) (interface{}, error) {
	pushes, err := strconv.Atoi(r.FormValue("iterations"))
	if err != nil {
		pushes = 1
	}

	concurrency, err := strconv.Atoi(r.FormValue("concurrency"))
	if err != nil {
		concurrency = 1
	}

	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 = "push"
	}

	//ToDo (simon): interval and stop is 0, repeating at interval is not yet exposed in Web UI
	workloadList := workloads.DefaultWorkloadList()
	worker := benchmarker.NewWorker()
	workloadList.DescribeWorkloads(worker)

	experiment, _ := ctx.lab.Run(
		NewRunnableExperiment(
			NewExperimentConfiguration(
				pushes, concurrency, interval, stop, worker, workload)))

	return ctx.router.Get("experiment").URL("name", experiment.GetGuid())
}
Ejemplo n.º 2
0
		fmt.Printf("Invalid workload: '%s'\n\n", err)
		fmt.Println("Available workloads:\n")
		worker.Visit(PrintWorkload)
		return err
	}

	return then()
}

var LaboratoryFactory = func(store Store) (lab Laboratory) {
	lab = NewLaboratory(store)
	return
}

var WorkerFactory = func() (worker benchmarker.Worker) {
	worker = benchmarker.NewWorker()
	workloadList.DescribeWorkloads(worker)
	return
}

var BlockExit = func() {
	for {
		in := make([]byte, 1)
		os.Stdin.Read(in)
		if string(in) == "q" {
			return
		}
	}
}

var PrintWorkload = func(workload workloads.WorkloadStep) {