catapult: Limit number of samples in a Histogram
IN-199
Change-Id: I69755268629e7284fac68c10d8da0af07ab260e1
diff --git a/catapult/histogram.go b/catapult/histogram.go
index 76916af..7b24014 100644
--- a/catapult/histogram.go
+++ b/catapult/histogram.go
@@ -78,25 +78,34 @@
// Creates a histogram from the given variant and benchmark data set.
//
-// TODO(kjharland): Generalize to suppport non-zircon benchmarks once I have
+// TODO(kjharland): Generalize to support non-zircon benchmarks once I have
// a better idea of how other benchmarks will be converted.
func createHistogram(v schema.Variant, d schema.BenchmarkData) Histogram {
var sampleValues []float64
for _, sample := range d.Samples {
+ // The number of samples to take. Catapult will reject sample
+ // sets that are *too large*. Fuchsia tests usually generate
+ // ~10,000 - 20,000 sample points per test-run, but only a
+ // handful of these are needed.
+ //
+ // TODO(kjharland): Use a sane max of the first 1000 points for now.
+ // Find out how to properly split samples so that data is not thrown
+ // away.
+ numSamples := math.Min(1000, float64(len(sample.Values)))
+
// All zircon benchmarks use nanoseconds. Catapult doesn't support this,
// so convert to milliseconds instead.
- for _, nanoseconds := range sample.Values {
- sampleValues = append(sampleValues, nanoseconds/1e6)
+ for i := 0; i < int(numSamples); i++ {
+ sampleValues = append(sampleValues, sample.Values[i]/1e6)
}
}
return Histogram{
- Name: fmt.Sprintf("%v, %v", v.VariantDesc, d.Label),
- Unit: "ms_smallerIsBetter",
- GUID: uuid.NewV4().String(),
- NumNans: 0, // All samples are numeric values
- SampleValues: sampleValues,
- // FIXME(kjharland): Define a static value for maxNumSampleValues, but what?
+ Name: fmt.Sprintf("%v, %v", v.VariantDesc, d.Label),
+ Unit: "ms_smallerIsBetter",
+ GUID: uuid.NewV4().String(),
+ NumNans: 0, // All samples are numeric values
+ SampleValues: sampleValues,
MaxNumSampleValues: len(sampleValues),
Running: computeRunningStatistics(sampleValues),
}