refactor: remove dead code

This commit is contained in:
Matthias Radestock
2018-04-02 13:27:51 +01:00
parent 3a8cad1803
commit fd3ac19c02
2 changed files with 0 additions and 32 deletions

View File

@@ -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 {

View File

@@ -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)