Esempio n. 1
0
File: main.go Progetto: shramov/ring
func ping(ring *ring.Ring, count int) {
	for i := 0; i != count; i++ {
		pad := rand.Intn(100)
		//fmt.Println("ping", i)
		for ring.WriteString(fmt.Sprintf("data %.*d", pad, i)) != nil {
		}
	}
	for ring.WriteString("") != nil {
	}
}
Esempio n. 2
0
File: main.go Progetto: shramov/ring
func pong(ring *ring.Ring) {
	count, bytes := 0, 0
	begin := time.Now()
	for {
		data := ring.NextString()
		if data == nil {
			continue
		}

		count++
		bytes += len(*data)
		//fmt.Println("Pong", count, bytes, *data)
		if len(*data) == 0 {
			break
		}
	}
	t := time.Now().Sub(begin)
	fmt.Printf("Messages: %d; Bytes: %d; Time: %v\n", count, bytes, t)
	fmt.Printf("Speed: %.3fm/us\n", float64(count)/(1000000*t.Seconds()))
	done <- 1
}