Skip to content

Commit d1a11ea

Browse files
authored
Merge pull request #20 from essentialkaos/develop
Version 3.0.3
2 parents 39f1478 + a82f26a commit d1a11ea

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

common/redis-latency-monitor.spec

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Summary: Tiny Redis client for latency measurement
1212
Name: redis-latency-monitor
13-
Version: 3.0.2
13+
Version: 3.0.3
1414
Release: 0%{?dist}
1515
Group: Applications/System
1616
License: EKOL
@@ -58,6 +58,10 @@ rm -rf %{buildroot}
5858
################################################################################
5959

6060
%changelog
61+
* Wed Oct 31 2018 Anton Novojilov <[email protected]> - 3.0.3-0
62+
- Fixed bug with Max/Mean/StDev/Perc calculation
63+
- Minor UI improvements
64+
6165
* Sat Oct 20 2018 Anton Novojilov <[email protected]> - 3.0.2-0
6266
- Show usage info if '-h' passed without any value
6367

redis-latency-monitor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
// App info
3535
const (
3636
APP = "Redis Latency Monitor"
37-
VER = "3.0.2"
37+
VER = "3.0.3"
3838
DESC = "Tiny Redis client for latency measurement"
3939
)
4040

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

335335
if prettyOutput {
336336
t.Print(
337-
timeutil.Format(time.Now(), "%H:%M:%S.%K"),
337+
timeutil.Format(time.Now(), "%H:%M:%S{s-}.%K{!}"),
338338
fmtutil.PrettyNum(len(measurements)),
339339
fmtutil.PrettyNum(errors),
340340
formatNumber(min), formatNumber(max),
@@ -383,7 +383,7 @@ func formatNumber(value uint64) string {
383383
fv = mathutil.Round(fv, 2)
384384
}
385385

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

389389
// usToMs convert us in uint64 to ms in float64

stats/stats.go

+16
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,28 @@ func Min(d Data) uint64 {
6060

6161
// Max return maximum value in slice
6262
func Max(d Data) uint64 {
63+
if len(d) == 0 {
64+
return 0
65+
}
66+
6367
return d[len(d)-1]
6468
}
6569

6670
// Mean return average value
6771
func Mean(d Data) uint64 {
72+
if len(d) == 0 {
73+
return 0
74+
}
75+
6876
return d.Sum() / uint64(len(d))
6977
}
7078

7179
// StandardDeviation return amount of variation in the dataset
7280
func StandardDeviation(d Data) uint64 {
81+
if len(d) == 0 {
82+
return 0
83+
}
84+
7385
m := Mean(d)
7486

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

8698
// Percentile calculate percetile
8799
func Percentile(d Data, percent float64) uint64 {
100+
if len(d) == 0 {
101+
return 0
102+
}
103+
88104
if percent > 100 {
89105
return 0
90106
}

0 commit comments

Comments
 (0)