Skip to content

Commit

Permalink
Merge pull request #20 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 3.0.3
  • Loading branch information
andyone authored Nov 1, 2018
2 parents 39f1478 + a82f26a commit d1a11ea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion common/redis-latency-monitor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Summary: Tiny Redis client for latency measurement
Name: redis-latency-monitor
Version: 3.0.2
Version: 3.0.3
Release: 0%{?dist}
Group: Applications/System
License: EKOL
Expand Down Expand Up @@ -58,6 +58,10 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Wed Oct 31 2018 Anton Novojilov <[email protected]> - 3.0.3-0
- Fixed bug with Max/Mean/StDev/Perc calculation
- Minor UI improvements

* Sat Oct 20 2018 Anton Novojilov <[email protected]> - 3.0.2-0
- Show usage info if '-h' passed without any value

Expand Down
6 changes: 3 additions & 3 deletions redis-latency-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
// App info
const (
APP = "Redis Latency Monitor"
VER = "3.0.2"
VER = "3.0.3"
DESC = "Tiny Redis client for latency measurement"
)

Expand Down Expand Up @@ -334,7 +334,7 @@ func printMeasurements(t *table.Table, errors int, measurements stats.Data, pret

if prettyOutput {
t.Print(
timeutil.Format(time.Now(), "%H:%M:%S.%K"),
timeutil.Format(time.Now(), "%H:%M:%S{s-}.%K{!}"),
fmtutil.PrettyNum(len(measurements)),
fmtutil.PrettyNum(errors),
formatNumber(min), formatNumber(max),
Expand Down Expand Up @@ -383,7 +383,7 @@ func formatNumber(value uint64) string {
fv = mathutil.Round(fv, 2)
}

return strings.Replace(fmtutil.PrettyNum(fv), ".", "{s-}.", -1) + "{!}"
return strings.Replace(fmtutil.PrettyNum(fv), ".", "{s}.", -1) + "{!}"
}

// usToMs convert us in uint64 to ms in float64
Expand Down
16 changes: 16 additions & 0 deletions stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,28 @@ func Min(d Data) uint64 {

// Max return maximum value in slice
func Max(d Data) uint64 {
if len(d) == 0 {
return 0
}

return d[len(d)-1]
}

// Mean return average value
func Mean(d Data) uint64 {
if len(d) == 0 {
return 0
}

return d.Sum() / uint64(len(d))
}

// StandardDeviation return amount of variation in the dataset
func StandardDeviation(d Data) uint64 {
if len(d) == 0 {
return 0
}

m := Mean(d)

var variance int64
Expand All @@ -85,6 +97,10 @@ func StandardDeviation(d Data) uint64 {

// Percentile calculate percetile
func Percentile(d Data, percent float64) uint64 {
if len(d) == 0 {
return 0
}

if percent > 100 {
return 0
}
Expand Down

0 comments on commit d1a11ea

Please sign in to comment.