Convert units from ns to ms for zircon_benchmarks Change-Id: Id32b85044b0ce624b0f6819d056261d0bcec789d
diff --git a/catapult/histogram.go b/catapult/histogram.go index f216c5f..59e21f6 100644 --- a/catapult/histogram.go +++ b/catapult/histogram.go
@@ -15,6 +15,9 @@ // Histogram is a Catapult histogram object. // +// See https://github.com/catapult-project/catapult/blob/master/docs/histogram-set-json-format.md +// for more information on the format. +// // TODO(kjharland): Add these missing fields as needed // ShortName // BinBoundaries @@ -50,18 +53,22 @@ } // Creates a histogram from the given variant and benchmark data set. +// +// TODO(kjharland): Generalize to suppport 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 { - sampleValues = append(sampleValues, 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) + } } return Histogram{ - // FIXME(kjharland): Verify naming scheme with mseaborn@ - Name: fmt.Sprintf("%v, %v", v.VariantDesc, d.Label), - // FIXME(kjharland): nanoseconds (ns) is not supported. Check with catapult team - // or change granularity of benchmarks if possible. - Unit: d.Unit, + Name: fmt.Sprintf("%v, %v", v.VariantDesc, d.Label), + Unit: "timeInMsAutoFormat_smallerIsBetter", GUID: uuid.NewV4().String(), NumNans: 0, // All samples are numeric values SampleValues: sampleValues,
diff --git a/catapult/histogram_test.go b/catapult/histogram_test.go index b5ceb3b..ed4fb0b 100644 --- a/catapult/histogram_test.go +++ b/catapult/histogram_test.go
@@ -47,11 +47,25 @@ assert.Equal(s.T(), len(histogramSet), 1) assert.Equal(s.T(), histogram.Name, "example_variant, example_benchmark_data") assert.Len(s.T(), histogram.GUID, 36) - assert.Equal(s.T(), histogram.Unit, "ns") + assert.Equal(s.T(), histogram.Unit, "timeInMsAutoFormat_smallerIsBetter") assert.Empty(s.T(), histogram.Description) assert.Empty(s.T(), histogram.Diagnostics) - assert.ElementsMatch(s.T(), histogram.SampleValues, []float64{10, 20, 30, 40, 50}) + assert.ElementsMatch(s.T(), histogram.SampleValues, []float64{ + 1e-5, + 2e-5, + 3e-5, + 4e-5, + 5e-5, + }) assert.Equal(s.T(), histogram.MaxNumSampleValues, 5) assert.Equal(s.T(), histogram.NumNans, 0) - assert.ElementsMatch(s.T(), histogram.Running, []float64{5, 50, 0, 30, 10, 150, 250}) + assert.ElementsMatch(s.T(), histogram.Running, []float64{ + 5, // count + 5e-05, // max + 0, // meanlogs + 3.0000000000000004e-05, //mean + 1e-5, // min + 1.5000000000000001e-4, //sum + 2.5e-10, // variance + }) }