Skip to content

Commit

Permalink
cmd/multiping: rename stats
Browse files Browse the repository at this point in the history
It really is a history, which *generates* statistics :-)
  • Loading branch information
dmke committed Feb 23, 2018
1 parent 8758eb2 commit dfb14eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cmd/multiping/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
ping "github.com/digineo/go-ping"
)

type stats struct {
type history struct {
received int
lost int
results []time.Duration // ring buffer, index = .received
Expand All @@ -21,14 +21,14 @@ type destination struct {
host string
remote *net.IPAddr
display string
*stats
*history
}

func (u *destination) ping(pinger *ping.Pinger) {
u.addResult(pinger.PingRTT(u.remote))
}

func (s *stats) addResult(rtt time.Duration, err error) {
func (s *history) addResult(rtt time.Duration, err error) {
s.mtx.Lock()
if err == nil {
s.results[s.received%len(s.results)] = rtt
Expand All @@ -40,7 +40,7 @@ func (s *stats) addResult(rtt time.Duration, err error) {
s.mtx.Unlock()
}

func (s *stats) compute() (pktSent int, pktLoss float64, last, best, worst, mean, stddev time.Duration) {
func (s *history) compute() (pktSent int, pktLoss float64, last, best, worst, mean, stddev time.Duration) {
s.mtx.RLock()
defer s.mtx.RUnlock()

Expand Down
2 changes: 1 addition & 1 deletion cmd/multiping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
dst := destination{
host: host,
remote: &ipaddr,
stats: &stats{
history: &history{
results: make([]time.Duration, opts.statBufferSize),
},
}
Expand Down

0 comments on commit dfb14eb

Please sign in to comment.