Exemple #1
0
func (s *Scheme) RunWriter(writer factory.Writer) {
	if s.warmupMessagesPerRun > 0 {
		logs.Logger.Info("Writing %d warmup messages", s.warmupMessagesPerRun)
	}

	for i := 0; i < s.warmupMessagesPerRun; i++ {
		writer.Write(s.buffer)
	}

	if s.warmupMessagesPerRun > 0 {
		time.Sleep(s.warmupWait)
	}

	logs.Logger.Info("Starting writing %d messages...", s.messagesPerRun)
	startTime := time.Now()
	for i := 0; i < s.messagesPerRun; i++ {
		s.countMessage(writer.Write(s.buffer))
	}
	s.runTime = time.Now().Sub(startTime)
	logs.Logger.Info("Finished.")

	err := writer.Close()
	if err != nil {
		logs.Logger.Warning("Error closing writer, %s", err.Error())
	}

	s.outputReport()
}
Exemple #2
0
func (s *Scheme) RunWriter(writer factory.Writer) {
	s.closer = writer
	defer s.done.Done()
	s.startReporter()

	var ticker *time.Ticker
	if s.tickerTime > 0 {
		ticker = time.NewTicker(s.tickerTime)
		defer ticker.Stop()
	}

	for {
		if ticker != nil {
			<-ticker.C
		}

		if s.isClosed() {
			break
		}

		count, err := writer.Write(s.buffer)
		s.countMessage(count, err)
	}
}