-
Notifications
You must be signed in to change notification settings - Fork 444
/
benchmark.go
25 lines (19 loc) · 1.12 KB
/
benchmark.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package matchers
import (
"time"
"github.com/solo-io/gloo/test/gomega/transforms"
"github.com/onsi/gomega"
"github.com/onsi/gomega/types"
)
// HavePercentileLessThan returns a matcher requiring the given slice of durations to be less than the given upperBound at the given percentile
func HavePercentileLessThan(percentile int, upperBound time.Duration) types.GomegaMatcher {
return gomega.WithTransform(transforms.WithPercentile(percentile), gomega.BeNumerically("<", upperBound))
}
// HavePercentileWithin returns a matcher requiring the given slice of durations to be within a window of a given target at the given percentile
func HavePercentileWithin(percentile int, target, window time.Duration) types.GomegaMatcher {
return gomega.WithTransform(transforms.WithPercentile(percentile), gomega.BeNumerically("~", target, window))
}
// HaveMedianLessThan returns a matcher requiring the given slice of durations have a median value less than the given upperBound
func HaveMedianLessThan(upperBound time.Duration) types.GomegaMatcher {
return gomega.WithTransform(transforms.WithMedian(), gomega.BeNumerically("<", upperBound))
}