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
|
|
|
|
2022-12-06 07:41:09 +01:00
|
|
|
"github.com/TwiN/gatus/v5/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,
|
|
|
|
})
|
2021-10-23 22:47:12 +02:00
|
|
|
// Simulate an endpoint with an interval of 3 minutes
|
2021-04-18 06:51:47 +02:00
|
|
|
timestamp = timestamp.Add(3 * time.Minute)
|
|
|
|
}
|
|
|
|
b.ReportAllocs()
|
|
|
|
}
|