Пример #1
0
func Serve() {
	err := store.WithStore(func(store Store) error {
		ServeWithLab(NewLaboratory(store))
		return nil
	})

	if err != nil {
		panic(err)
	}
}
Пример #2
0
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
			})
		})
	})
}