This commit is contained in:
William Banfield
2022-09-01 17:49:25 -04:00
parent e768dee0cb
commit 9ad3132dc6
3 changed files with 15 additions and 10 deletions
+2 -1
View File
@@ -94,7 +94,8 @@ func GenerateFromBlockStore(s BlockStore) (Report, error) {
r.All = append(r.All, pd.l)
if pd.l > r.Max {
r.Max = pd.l
} else if pd.l < r.Min {
}
if pd.l < r.Min {
r.Min = pd.l
}
// Using an int64 here makes an assumption about the scale and quantity of the data we are processing.
+5 -4
View File
@@ -74,14 +74,15 @@ func TestGenerateReport(t *testing.T) {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 5*time.Second, r.Avg)
}
if r.Min != 4*time.Second {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 4*time.Second, r.Min)
t.Fatalf("Min did not match expected. Expected %s but contained %s", 4*time.Second, r.Min)
}
if r.Max != 6*time.Second {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 6*time.Second, r.Max)
t.Fatalf("Max did not match expected. Expected %s but contained %s", 6*time.Second, r.Max)
}
// Verified using online standard deviation calculator:
// https://www.calculator.net/standard-deviation-calculator.html?numberinputs=6%2C+4&ctype=p&x=84&y=27
if r.StdDev != time.Second {
t.Fatalf("StdDev did not match expected. Expected %s but contained %s", time.Second, r.StdDev)
expectedStdDev := 1414213562 * time.Nanosecond
if r.StdDev != expectedStdDev {
t.Fatalf("StdDev did not match expected. Expected %s but contained %s", expectedStdDev, r.StdDev)
}
}