From 075997f12e2fb2b646172a92926be0f26f739099 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Tue, 27 Oct 2009 22:01:09 -0700 Subject: PerformanceCollector: Collect & report perf measurements in key/value form - Added new functions to PerformanceCollector and PerformanceResultsWriter - Modified unit tests to test new functionality and fix flakiness reported in 2218327 and 2118268 - Added PerformanceCollectorTest to small suite --- core/java/android/os/PerformanceCollector.java | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'core/java/android/os') diff --git a/core/java/android/os/PerformanceCollector.java b/core/java/android/os/PerformanceCollector.java index 4ca1f32..be1cf6d 100644 --- a/core/java/android/os/PerformanceCollector.java +++ b/core/java/android/os/PerformanceCollector.java @@ -107,6 +107,36 @@ public class PerformanceCollector { * @see PerformanceCollector#stopTiming(String) */ public void writeStopTiming(Bundle results); + + /** + * Callback invoked as last action in + * {@link PerformanceCollector#addMeasurement(String, long)} for + * reporting an integer type measurement. + * + * @param label short description of the metric that was measured + * @param value long value of the measurement + */ + public void writeMeasurement(String label, long value); + + /** + * Callback invoked as last action in + * {@link PerformanceCollector#addMeasurement(String, float)} for + * reporting a float type measurement. + * + * @param label short description of the metric that was measured + * @param value float value of the measurement + */ + public void writeMeasurement(String label, float value); + + /** + * Callback invoked as last action in + * {@link PerformanceCollector#addMeasurement(String, String)} for + * reporting a string field. + * + * @param label short description of the metric that was measured + * @param value string summary of the measurement + */ + public void writeMeasurement(String label, String value); } /** @@ -385,6 +415,39 @@ public class PerformanceCollector { return mPerfMeasurement; } + /** + * Add an integer type measurement to the collector. + * + * @param label short description of the metric that was measured + * @param value long value of the measurement + */ + public void addMeasurement(String label, long value) { + if (mPerfWriter != null) + mPerfWriter.writeMeasurement(label, value); + } + + /** + * Add a float type measurement to the collector. + * + * @param label short description of the metric that was measured + * @param value float value of the measurement + */ + public void addMeasurement(String label, float value) { + if (mPerfWriter != null) + mPerfWriter.writeMeasurement(label, value); + } + + /** + * Add a string field to the collector. + * + * @param label short description of the metric that was measured + * @param value string summary of the measurement + */ + public void addMeasurement(String label, String value) { + if (mPerfWriter != null) + mPerfWriter.writeMeasurement(label, value); + } + /* * Starts tracking memory usage, binder transactions, and real & cpu timing. */ -- cgit v1.1