mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-16 03:49:52 +00:00
refactor: remove dead code
This commit is contained in:
@@ -199,23 +199,6 @@ func (m Metric) Merge(other Metric) Metric {
|
||||
}
|
||||
}
|
||||
|
||||
// Div returns a new copy of the metric, with each value divided by n.
|
||||
func (m Metric) Div(n float64) Metric {
|
||||
samplesOut := make([]Sample, len(m.Samples), len(m.Samples))
|
||||
|
||||
for i := range m.Samples {
|
||||
samplesOut[i].Value = m.Samples[i].Value / n
|
||||
samplesOut[i].Timestamp = m.Samples[i].Timestamp
|
||||
}
|
||||
return Metric{
|
||||
Samples: samplesOut,
|
||||
Max: m.Max / n,
|
||||
Min: m.Min / n,
|
||||
First: m.First,
|
||||
Last: m.Last,
|
||||
}
|
||||
}
|
||||
|
||||
// LastSample obtains the last sample of the metric
|
||||
func (m Metric) LastSample() (Sample, bool) {
|
||||
if m.Samples == nil {
|
||||
|
||||
@@ -122,21 +122,6 @@ func TestMetricMerge(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMetricDiv(t *testing.T) {
|
||||
t1 := time.Now()
|
||||
t2 := time.Now().Add(1 * time.Minute)
|
||||
|
||||
want := report.MakeMetric([]report.Sample{{Timestamp: t1, Value: -2}, {Timestamp: t2, Value: 2}})
|
||||
beforeDiv := report.MakeMetric([]report.Sample{{Timestamp: t1, Value: -2048}, {Timestamp: t2, Value: 2048}})
|
||||
have := beforeDiv.Div(1024)
|
||||
if !reflect.DeepEqual(want, have) {
|
||||
t.Errorf("diff: %s", test.Diff(want, have))
|
||||
}
|
||||
|
||||
// Check the original was unmodified
|
||||
checkMetric(t, beforeDiv, t1, t2, -2048, 2048)
|
||||
}
|
||||
|
||||
func TestMetricMarshalling(t *testing.T) {
|
||||
t1 := time.Now().UTC()
|
||||
t2 := time.Now().UTC().Add(1 * time.Minute)
|
||||
|
||||
Reference in New Issue
Block a user