Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2018-10-30 20:51:04 +0300
committerBen Kochie <superq@gmail.com>2018-10-30 20:51:04 +0300
commitf291b83bbce73f8f0bc6f9e98eb0ffebf2afcea3 (patch)
tree129bb5c2995a2596b4a5b7ea332e18677e74c7a1
parent8ca6ca8f39279edaa6e62de7b8b3407ff9d644a3 (diff)
Update vendor github.com/beorn7/perks/quantile@master
-rw-r--r--vendor/github.com/beorn7/perks/quantile/stream.go34
-rw-r--r--vendor/vendor.json8
2 files changed, 34 insertions, 8 deletions
diff --git a/vendor/github.com/beorn7/perks/quantile/stream.go b/vendor/github.com/beorn7/perks/quantile/stream.go
index f4cabd669..d7d14f8eb 100644
--- a/vendor/github.com/beorn7/perks/quantile/stream.go
+++ b/vendor/github.com/beorn7/perks/quantile/stream.go
@@ -77,15 +77,20 @@ func NewHighBiased(epsilon float64) *Stream {
// is guaranteed to be within (Quantile±Epsilon).
//
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error properties.
-func NewTargeted(targets map[float64]float64) *Stream {
+func NewTargeted(targetMap map[float64]float64) *Stream {
+ // Convert map to slice to avoid slow iterations on a map.
+ // ƒ is called on the hot path, so converting the map to a slice
+ // beforehand results in significant CPU savings.
+ targets := targetMapToSlice(targetMap)
+
ƒ := func(s *stream, r float64) float64 {
var m = math.MaxFloat64
var f float64
- for quantile, epsilon := range targets {
- if quantile*s.n <= r {
- f = (2 * epsilon * r) / quantile
+ for _, t := range targets {
+ if t.quantile*s.n <= r {
+ f = (2 * t.epsilon * r) / t.quantile
} else {
- f = (2 * epsilon * (s.n - r)) / (1 - quantile)
+ f = (2 * t.epsilon * (s.n - r)) / (1 - t.quantile)
}
if f < m {
m = f
@@ -96,6 +101,25 @@ func NewTargeted(targets map[float64]float64) *Stream {
return newStream(ƒ)
}
+type target struct {
+ quantile float64
+ epsilon float64
+}
+
+func targetMapToSlice(targetMap map[float64]float64) []target {
+ targets := make([]target, 0, len(targetMap))
+
+ for quantile, epsilon := range targetMap {
+ t := target{
+ quantile: quantile,
+ epsilon: epsilon,
+ }
+ targets = append(targets, t)
+ }
+
+ return targets
+}
+
// Stream computes quantiles for a stream of float64s. It is not thread-safe by
// design. Take care when using across multiple goroutines.
type Stream struct {
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 3ef4fc12c..89c8083b3 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -11,10 +11,12 @@
"versionExact": "v0.3.1"
},
{
- "checksumSHA1": "spyv5/YFBjYyZLZa1U2LBfDR8PM=",
+ "checksumSHA1": "0rido7hYHQtfq3UJzVT5LClLAWc=",
"path": "github.com/beorn7/perks/quantile",
- "revision": "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9",
- "revisionTime": "2016-08-04T10:47:26Z"
+ "revision": "3a771d992973f24aa725d07868b467d1ddfceafb",
+ "revisionTime": "2018-03-21T16:47:47Z",
+ "version": "master",
+ "versionExact": "master"
},
{
"checksumSHA1": "0hWqEc//bdHUtnxlAo/UPkHSIS0=",