Esempio n. 1
0
func RunCommandLine(concurrency int, iterations int, silent bool, name string, interval int, stop int, workload string) (err error) {
	handlers := make([]func(<-chan *Sample), 0)

	if !silent {
		handlers = append(handlers, func(s <-chan *Sample) { display(concurrency, iterations, interval, stop, s) })
	}

	worker := benchmarker.NewWorker()
	worker.AddExperiment("login", experiments.Dummy)
	worker.AddExperiment("push", experiments.Push)
	worker.AddExperiment("dummy", experiments.Dummy)
	worker.AddExperiment("dummyWithErrors", experiments.DummyWithErrors)

	NewLaboratory(store.NewCsvStore("output/csvs")).RunWithHandlers(
		NewRunnableExperiment(
			NewExperimentConfiguration(
				iterations, concurrency, interval, stop, worker, workload)), handlers)

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

	return nil
}
Esempio n. 2
0
func RunCommandLine() error {
	lab := NewLaboratory(store.NewCsvStore("output/csvs"))
	worker := benchmarker.NewWorker()
	err := RunCommandLineWithLabAndWorker(lab, worker)

	for {
		in := make([]byte, 1)
		os.Stdin.Read(in)
		if string(in) == "q" {
			return err
		}
	}
}
Esempio n. 3
0
func ServeWithArgs(csvDir string) {
	ServeWithLab(NewLaboratory(store.NewCsvStore(csvDir)))
}
Esempio n. 4
0
	)

	BeforeEach(func() {
		experiments := []*DummyExperiment{&DummyExperiment{"a"}, &DummyExperiment{"b"}, &DummyExperiment{"c"}}
		lab = &DummyLab{}
		lab.experiments = experiments
		http.DefaultServeMux = http.NewServeMux()
		ServeWithLab(lab)
	})

	It("Uses config to get CSV output directory", func() {
		http.DefaultServeMux = http.NewServeMux()
		c := config.NewConfig()
		InitCommandLineFlags(c)
		c.Parse([]string{"-csvDir", "/var/tmp/foo/bar/"})
		csvs := store.NewCsvStore("/var/tmp/foo/bar/")
		ch := make(chan *Sample)
		go func() { ch <- &Sample{}; ch <- &Sample{}; close(ch) }()
		csvs.Writer("1234")(ch)

		Serve()
		json := get("/experiments/1234")
		Ω(json["Items"]).Should(HaveLen(2))
	})

	It("lists experiments", func() {
		json := get("/experiments/")
		Ω(json["Items"]).Should(HaveLen(3))
		items := json["Items"].([]interface{})
		Ω(items[0].(map[string]interface{})["Location"]).Should(Equal("/experiments/a"))
		Ω(items[1].(map[string]interface{})["Location"]).Should(Equal("/experiments/b"))