예제 #1
0
func main() {
	numCPU := runtime.NumCPU()
	runtime.GOMAXPROCS(numCPU)

	obliteration := flag.Int("concurrency", 10, "threads and connections to use for load generation")
	host := flag.String("zk", "master.mesos:2181", "host:port for zk")
	size := flag.Int("size", 1024, "bytes per key written")
	ratio := flag.Float64("ratio", 0.2, "0 to 1 ratio of reads to writes.  0 is all writes, 1 is all reads.")
	flag.Parse()

	value := gen(*size)

	conns := []*zk.Conn{}
	for i := 0; i < *obliteration; i++ {
		cli, _, err := zk.Connect([]string{*host}, 5*time.Second)
		if err != nil {
			fmt.Printf("error connecting to zk: %v\n", err)
			os.Exit(1)
		}
		conns = append(conns, cli)
	}

	doRpc := func() {
		cli := conns[rand.Intn(len(conns))]
		bench(cli, value, *ratio)
	}

	loghisto.PrintBenchmark("benchmark1234", uint(*obliteration), doRpc)
}
예제 #2
0
func main() {
	numCPU := runtime.NumCPU()
	runtime.GOMAXPROCS(numCPU)

	fire := make(chan struct{})
	for i := 0; i < 8; i++ {
		go func() {
			conn, err := net.Dial("tcp", "localhost:8880")
			if err != nil {
				fmt.Errorf("could not connect: %v", err)
				return
			}
			for {
				<-fire
				benchmark(conn)
			}
		}()
	}

	desiredConcurrency := uint(10)
	loghisto.PrintBenchmark("benchmark1234", desiredConcurrency, func() { fire <- struct{}{} })
}