diff options
| author | Paul Bütow <pbuetow@mimecast.com> | 2020-01-20 18:41:05 +0000 |
|---|---|---|
| committer | Paul Bütow <pbuetow@mimecast.com> | 2020-01-21 14:35:23 +0000 |
| commit | c128865c4c7411c29a59fca9a3a2f95537686d7b (patch) | |
| tree | 193bccc70d942c8b70cc93fae2670263701e43aa /fs/stats.go | |
| parent | 3755a9911ecb05886577095f2b8cc8b9e4066a3a (diff) | |
Move commands to cmd/ and move internal dependencies to internal/
Diffstat (limited to 'fs/stats.go')
| -rw-r--r-- | fs/stats.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/fs/stats.go b/fs/stats.go deleted file mode 100644 index 4121ff7..0000000 --- a/fs/stats.go +++ /dev/null @@ -1,69 +0,0 @@ -package fs - -// Used to calculate how many log lines matched the regular expression -// and how many log files could be transmitted from the server to the client. -// Hit and transmit percentage takes only the last 100 log lines into calculation. -type stats struct { - pos int - lineCount uint64 - matched [100]bool - matchCount uint64 - transmitted [100]bool - transmitCount int -} - -// Return the total line count. -func (f *stats) totalLineCount() uint64 { - return f.lineCount -} - -// Calculate the percentage of log lines transmitted to the client. -func (f *stats) transmittedPerc() int { - return int(percentOf(float64(f.matchCount), float64(f.transmitCount))) -} - -// Update bucket position. We only take into consideration the last 100 -// lines for stats. -func (f *stats) updatePosition() { - f.pos = (f.pos + 1) % 100 - f.lineCount++ -} - -// Increment match counter. -func (f *stats) updateLineMatched() { - if !f.matched[f.pos] { - f.matchCount++ - f.matched[f.pos] = true - } -} - -// Increment transmitted counter. -func (f *stats) updateLineTransmitted() { - if !f.transmitted[f.pos] { - f.transmitCount++ - f.transmitted[f.pos] = true - } -} - -// Decrement match counter. -func (f *stats) updateLineNotMatched() { - if f.matched[f.pos] { - f.matchCount-- - f.matched[f.pos] = false - } -} - -// Decrement transmitted counter. -func (f *stats) updateLineNotTransmitted() { - if f.transmitted[f.pos] { - f.transmitCount-- - f.transmitted[f.pos] = false - } -} - -func percentOf(total float64, value float64) float64 { - if total == 0 || total == value { - return 100 - } - return value / (total / 100.0) -} |
