Beispiel #1
0
func runRecv(iterations int, profile bool) {
	if profile {
		f, err := os.Create("recv.profile")
		if err != nil {
			panic(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
		f, err = os.Create("recv.mem")
		if err != nil {
			panic(err)
		}
		defer func() {
			pprof.WriteHeapProfile(f)
			f.Close()
		}()
	}
	listener := newListener("", iterations)
	_, err := hyenad.NewHyenaClient(2, listener)
	if err != nil {
		panic(err)
	}
	log.WithField("Waiting for messages", iterations).Info("Receiving Client started")
	listener.wait.Wait()
	duration := time.Since(listener.startTime)
	msgPerS := float64(iterations) / float64(duration.Seconds())
	log.WithField("Messages", iterations).WithField("Time", duration.String()).WithField("Msg/S", msgPerS).Info("Done")
}
Beispiel #2
0
func CreateGateHandler() (*GateHandler, error) {
	res := GateHandler{}
	var err error
	res.client, err = hyenad.NewHyenaClient(1, &res)
	res.pendings = make(map[hyenad.MsgId]PendingResponse)
	go res.gc()
	return &res, err
}
Beispiel #3
0
func runSend(iterations int, profile bool) {
	if profile {
		f, err := os.Create("send.cpu")
		if err != nil {
			panic(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
		f, err = os.Create("send.mem")
		if err != nil {
			panic(err)
		}
		defer func() {
			pprof.WriteHeapProfile(f)
			f.Close()
		}()
	}
	listener := newListener("", 0)
	client, err := hyenad.NewHyenaClient(1, listener)
	if err != nil {
		panic(err)
	}
	target := 2
	dest := fmt.Sprintf("s:/test%v/toto/tata", target)
	log.Info("Sending Client started")
	bigString := strings.Repeat("Test", 40)
	start := time.Now()
	for i := 0; i < iterations; i++ {
		message := fmt.Sprintf("Message %v from Process %v, [%v]", i, 1, bigString)
		if i == 0 {
			log.WithField("MessageLength", len(message)).Info("Message created")
		}
		reader := bytes.NewReader([]byte(message))
		client.StreamTo(dest, reader)
		if i%5000 == 0 {
			log.WithField("Messages", i).Info("Sending Messages")
		}
	}
	duration := time.Since(start)
	listener.wait.Wait()
	msgPerS := float64(iterations) / float64(duration.Seconds())
	log.WithField("Messages", iterations).WithField("Time", duration.String()).WithField("Msg/S", msgPerS).Info("Done")
}
Beispiel #4
0
func runOnce(pid uint32) {
	listener := newListener("", 1)
	client, err := hyenad.NewHyenaClient(pid, listener)
	if err != nil {
		panic(err)
	}
	target := 1
	if pid == 1 {
		target = 2
	}
	dest := fmt.Sprintf("s:/test%v/toto/tata", target)
	log.WithField("pid", pid).Info("Client started")
	time.Sleep(5 * time.Second)
	message := fmt.Sprintf("Message from Process %v", pid)
	reader := bytes.NewReader([]byte(message))
	log.Info("Sending message")
	client.StreamTo(dest, reader)
	log.Info("Message sent")
	listener.wait.Wait()
	log.Info("Done")
}