Beispiel #1
0
func main() {

	args, err := docopt.Parse(usage, nil, true, "go_kafka_client_benchmark v0.1", true)
	if err != nil {
		fatal(err)
	}

	if v := args["--broker"]; v != nil {
		globalBrokerList = v.(string)
	}

	if v := args["--zk"]; v != nil {
		globalZkList = v.(string)
	}

	if v := args["--topic"]; v != nil {
		globalTopic = v.(string)
	}

	ncpu, err := utils.GetIntFromArgs(args, "--cpu", runtime.NumCPU())
	if err != nil {
		fatal(err)
	}

	globalMsgLength, err = utils.GetIntFromArgs(args, "--len", globalMsgLength)
	if err != nil {
		fatal(err)
	}

	globalConcurrentLevel, err = utils.GetIntFromArgs(args, "--cc", globalConcurrentLevel)
	if err != nil {
		fatal(err)
	}

	globalDuration, err = utils.GetIntFromArgs(args, "--time", globalDuration)
	if err != nil {
		fatal(err)
	}

	runtime.GOMAXPROCS(ncpu)

	if v := args["--addr"]; v != nil {
		httpAddr := v.(string)
		go func() {
			fatal(errors.Trace(http.ListenAndServe(httpAddr, nil)))
		}()
	}
	cmd := args["<command>"].(string)

	err = runCommand(cmd)
	if err != nil {
		fatal(err)
	}
}
Beispiel #2
0
func main() {

	var err error
	args, err := docopt.Parse(usage, nil, true, "qservice benchmark v0.1", true)
	if err != nil {
		fatal(err)
	}

	ncpu, err := utils.GetIntFromArgs(args, "--cpu", runtime.NumCPU())
	if err != nil {
		fatal(err)
	}

	if v := args["--host"]; v != nil {
		globalHost = v.(string)
	}

	if v := args["--queue"]; v != nil {
		globalQueue = v.(string)
	}

	if v := args["--biz"]; v != nil {
		globalBiz = v.(string)
	}

	globalMsgLength, err = utils.GetIntFromArgs(args, "--len", globalMsgLength)
	if err != nil {
		fatal(err)
	}

	globalConcurrentLevel, err = utils.GetIntFromArgs(args, "--cc", globalConcurrentLevel)
	if err != nil {
		fatal(err)
	}

	globalDuration, err = utils.GetIntFromArgs(args, "--time", globalDuration)
	if err != nil {
		fatal(err)
	}

	runtime.GOMAXPROCS(ncpu)

	cmd := args["<command>"].(string)
	cmdArgs := args["<args>"].([]string)

	err = runCommand(cmd, cmdArgs)
	if err != nil {
		fatal(err)
	}
}