2021-07-15 04:26:51 +02:00
|
|
|
package memory
|
2021-04-18 06:51:47 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
2021-07-15 04:26:51 +02:00
|
|
|
|
|
|
|
"github.com/TwinProduction/gatus/core"
|
2021-04-18 06:51:47 +02:00
|
|
|
)
|
|
|
|
|
2021-07-15 04:26:51 +02:00
|
|
|
func BenchmarkProcessUptimeAfterResult(b *testing.B) {
|
|
|
|
uptime := core.NewUptime()
|
2021-04-18 06:51:47 +02:00
|
|
|
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++ {
|
2021-07-15 04:26:51 +02:00
|
|
|
processUptimeAfterResult(uptime, &core.Result{
|
2021-04-18 06:51:47 +02:00
|
|
|
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()
|
|
|
|
}
|