1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// Copyright 2019-2022 Graham Clark. All rights reserved. Use of this source
// code is governed by the MIT license that can be found in the LICENSE
// file.
package pcap
import (
"github.com/gcla/gowid/gwutil"
)
//======================================================================
type averageTracker struct {
count uint64
total uint64
}
func (a averageTracker) average() gwutil.IntOption {
if a.count == 0 {
return gwutil.NoneInt()
}
return gwutil.SomeInt(int(a.total / a.count))
}
func (a *averageTracker) update(more int) {
a.count += 1
a.total += uint64(more)
}
type maxTracker struct {
cur int
}
func (a maxTracker) max() int {
return a.cur
}
func (a *maxTracker) update(candidate int) {
if candidate > a.cur {
a.cur = candidate
}
}
//======================================================================
// Local Variables:
// mode: Go
// fill-column: 78
// End:
|