MovieNight/stats.go
Zorchenhimer ec0c6752bc Fix some imports
Whoops.
2019-03-30 16:20:56 -04:00

37 lines
643 B
Go

package main
import (
"sync"
"time"
"github.com/zorchenhimer/MovieNight/common"
)
type streamStats struct {
messageIn int
messageOut int
start time.Time
mutex sync.Mutex
}
func newStreamStats() streamStats {
return streamStats{start: time.Now()}
}
func (s *streamStats) msgInInc() {
s.mutex.Lock()
s.messageIn++
s.mutex.Unlock()
}
func (s *streamStats) msgOutInc() {
s.mutex.Lock()
s.messageOut++
s.mutex.Unlock()
}
func (s *streamStats) Print() {
common.LogInfof("Messages In: %d\n", s.messageIn)
common.LogInfof("Messages Out: %d\n", s.messageOut)
common.LogInfof("Total Time: %s\n", time.Since(s.start))
}