diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 512e2127e6b0a..360e5c68675b7 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -34,6 +34,7 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Map; import org.apache.harmony.dalvik.ddmc.Chunk; import org.apache.harmony.dalvik.ddmc.ChunkHandler; @@ -1100,6 +1101,95 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo VMDebug.resetAllocCount(VMDebug.KIND_ALL_COUNTS); } + /** + * Returns the value of a particular runtime statistic or {@code null} if no + * such runtime statistic exists. + * + *

The following table lists the runtime statistics that the runtime supports. + * Note runtime statistics may be added or removed in a future API level.

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Runtime statistic nameMeaningExampleSupported (API Levels)
art.gc.gc-countThe number of garbage collection runs.{@code 164}23
art.gc.gc-timeThe total duration of garbage collection runs in ms.{@code 62364}23
art.gc.bytes-allocatedThe total number of bytes that the application allocated.{@code 1463948408}23
art.gc.bytes-freedThe total number of bytes that garbage collection reclaimed.{@code 1313493084}23
art.gc.blocking-gc-countThe number of blocking garbage collection runs.{@code 2}23
art.gc.blocking-gc-timeThe total duration of blocking garbage collection runs in ms.{@code 804}23
art.gc.gc-count-rate-histogramThe histogram of the number of garbage collection runs per 10 seconds.{@code 0:34503,1:45350,2:11281,3:8088,4:43,5:8}23
art.gc.blocking-gc-count-rate-histogramThe histogram of the number of garbage collection runs per 10 seconds.{@code 0:99269,1:1,2:1}23
+ * + * @param statName + * the name of the runtime statistic to look up. + * @return the value of the specified runtime statistic or {@code null} if the + * runtime statistic doesn't exist. + * @hide + */ + public static String getRuntimeStat(String statName) { + return VMDebug.getRuntimeStat(statName); + } + + /** + * Returns a map of the names/values of the runtime statistics + * that {@link #getRuntimeStat()} supports. + * + * @return a map of the names/values of the supported runtime statistics. + * @hide + */ + public static Map getRuntimeStats() { + return VMDebug.getRuntimeStats(); + } + /** * Returns the size of the native heap. * @return The size of the native heap in bytes.