示例#1
0
func gringoRunner() {
	doneChan := make(chan int)

	var r1 *gringo.Gringo = gringo.NewGringo()
	var r2 *gringo.Gringo = gringo.NewGringo()

	var startTime time.Time = time.Now()

	go gringoProducer(r1, doneChan)
	go gringoForwarder(r1, r2, doneChan)
	go gringoConsumer(r2, doneChan)

	<-doneChan
	<-doneChan
	<-doneChan

	fmt.Println("gringoRunner seconds passed:", time.Since(startTime))
}
示例#2
0
func BenchmarkGringo(b *testing.B) {
	q := gringo.NewGringo()
	var wg sync.WaitGroup
	wg.Add(1)
	b.StartTimer()
	go func() {
		defer wg.Done()
		for i := 0; i < b.N; i++ {
			q.Write(payload)
		}
	}()
	for i := 0; i < b.N; i++ {
		q.Read()
	}
	wg.Wait()
}