Unify uptime hourly metrics under Uptime.HourlyStatistics and add metric for response time

This commit is contained in:
TwinProduction
2021-04-18 00:51:47 -04:00
parent 347297a8ea
commit e91462ce41
3 changed files with 134 additions and 39 deletions

24
core/uptime_bench_test.go Normal file
View File

@ -0,0 +1,24 @@
package core
import (
"testing"
"time"
)
func BenchmarkUptime_ProcessResult(b *testing.B) {
uptime := NewUptime()
now := time.Now()
now = time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location())
// Start 12000 days ago
timestamp := now.Add(-12000 * 24 * time.Hour)
for n := 0; n < b.N; n++ {
uptime.ProcessResult(&Result{
Duration: 18 * time.Millisecond,
Success: n%15 == 0,
Timestamp: timestamp,
})
// Simulate service with an interval of 3 minutes
timestamp = timestamp.Add(3 * time.Minute)
}
b.ReportAllocs()
}