metrics: fix issues reported by staticcheck (#20365)

This commit is contained in:
Guillaume Ballet
2019-11-22 16:04:35 +01:00
committed by Felix Lange
parent dd21f079e8
commit 58f2ce8671
15 changed files with 109 additions and 105 deletions

View File

@ -22,27 +22,27 @@ func TestRuntimeMemStats(t *testing.T) {
zero := runtimeMetrics.MemStats.PauseNs.Count() // Get a "zero" since GC may have run before these tests.
runtime.GC()
CaptureRuntimeMemStatsOnce(r)
if count := runtimeMetrics.MemStats.PauseNs.Count(); 1 != count-zero {
if count := runtimeMetrics.MemStats.PauseNs.Count(); count-zero != 1 {
t.Fatal(count - zero)
}
runtime.GC()
runtime.GC()
CaptureRuntimeMemStatsOnce(r)
if count := runtimeMetrics.MemStats.PauseNs.Count(); 3 != count-zero {
if count := runtimeMetrics.MemStats.PauseNs.Count(); count-zero != 3 {
t.Fatal(count - zero)
}
for i := 0; i < 256; i++ {
runtime.GC()
}
CaptureRuntimeMemStatsOnce(r)
if count := runtimeMetrics.MemStats.PauseNs.Count(); 259 != count-zero {
if count := runtimeMetrics.MemStats.PauseNs.Count(); count-zero != 259 {
t.Fatal(count - zero)
}
for i := 0; i < 257; i++ {
runtime.GC()
}
CaptureRuntimeMemStatsOnce(r)
if count := runtimeMetrics.MemStats.PauseNs.Count(); 515 != count-zero { // We lost one because there were too many GCs between captures.
if count := runtimeMetrics.MemStats.PauseNs.Count(); count-zero != 515 { // We lost one because there were too many GCs between captures.
t.Fatal(count - zero)
}
}