示例#1
0
文件: server.go 项目: knolleary/pat
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())
}
示例#2
0
文件: cmdline.go 项目: knolleary/pat
	TotalTime int64
	Timestamp int64
}

var params = struct {
	iterations    int
	listWorkloads bool
	concurrency   int
	silent        bool
	output        string
	workload      string
	interval      int
	stop          int
}{}

var workloadList = workloads.DefaultWorkloadList()

func InitCommandLineFlags(config config.Config) {
	config.IntVar(&params.iterations, "iterations", 1, "number of pushes to attempt")
	config.IntVar(&params.concurrency, "concurrency", 1, "max number of pushes to attempt in parallel")
	config.BoolVar(&params.silent, "silent", false, "true to run the commands and print output the terminal")
	config.StringVar(&params.output, "output", "", "if specified, writes benchmark results to a CSV file")
	config.StringVar(&params.workload, "workload", "gcf:push", "a comma-separated list of operations a user should issue (use -list-workloads to see available workload options)")
	config.IntVar(&params.interval, "interval", 0, "repeat a workload at n second interval, to be used with -stop")
	config.IntVar(&params.stop, "stop", 0, "stop a repeating interval after n second, to be used with -interval")
	config.BoolVar(&params.listWorkloads, "list-workloads", false, "Lists the available workloads")
	workloadList.DescribeParameters(config)
	store.DescribeParameters(config)
}

func RunCommandLine() error {