Files
argo-cd/util/stats/stats_test.go
Jesse Suen 476b09cbbf feat: improve api-server and controller performance (#3222)
* group read comparison settings during app reconciliation
* Reduce lock contention in clusterInfo::ensureSynced(). Add getRepoObj stats
* Remove additional source of lock contention
* Exclude the coordination.k8s.io/Lease resource

Co-authored-by: Alexander Matyushentsev <amatyushentsev@gmail.com>
2020-03-16 11:51:59 -07:00

32 lines
643 B
Go

package stats
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTimingStats(t *testing.T) {
start := time.Now()
now = func() time.Time {
return start
}
defer func() {
now = time.Now
}()
ts := NewTimingStats()
now = func() time.Time {
return start.Add(100 * time.Millisecond)
}
ts.AddCheckpoint("checkpoint-1")
now = func() time.Time {
return start.Add(300 * time.Millisecond)
}
ts.AddCheckpoint("checkpoint-2")
timings := ts.Timings()
assert.Len(t, timings, 2)
assert.Equal(t, 100*time.Millisecond, timings["checkpoint-1"])
assert.Equal(t, 200*time.Millisecond, timings["checkpoint-2"])
}