/**@class android.os.PerformanceCollector @extends java.lang.Object Collects performance data between two function calls in Bundle objects and outputs the results using writer of type {@link android.os.PerformanceCollector.PerformanceResultsWriter}. <p> {@link #beginSnapshot}(String) and {@link #endSnapshot}() functions collect memory usage information and measure runtime between calls to begin and end. These functions logically wrap around an entire test, and should be called with name of test as the label, e.g. EmailPerformanceTest. <p> {@link #startTiming}(String) and {@link #stopTiming}(String) functions measure runtime between calls to start and stop. These functions logically wrap around a single test case or a small block of code, and should be called with the name of test case as the label, e.g. testSimpleSendMailSequence. <p> {@link #addIteration}(String) inserts intermediate measurement point which can be labeled with a String, e.g. Launch email app, compose, send, etc. <p> Snapshot and timing functions do not interfere with each other, and thus can be called in any order. The intended structure is to wrap begin/endSnapshot around calls to start/stopTiming, for example: <p> <code>beginSnapshot("EmailPerformanceTest"); startTiming("testSimpleSendSequence"); addIteration("Launch email app"); addIteration("Compose"); stopTiming("Send"); startTiming("testComplexSendSequence"); stopTiming(""); startTiming("testAddLabel"); stopTiming(""); endSnapshot();</code> <p> Structure of results output is up to implementor of {@link android.os.PerformanceCollector.PerformanceResultsWriter }. {@hide} Pending approval for public API. */ var PerformanceCollector = { /** In a results Bundle, this key references a List of iteration Bundles. */ METRIC_KEY_ITERATIONS : "iterations", /** In an iteration Bundle, this key describes the iteration. */ METRIC_KEY_LABEL : "label", /** In a results Bundle, this key reports the cpu time of the code block under measurement. */ METRIC_KEY_CPU_TIME : "cpu_time", /** In a results Bundle, this key reports the execution time of the code block under measurement. */ METRIC_KEY_EXECUTION_TIME : "execution_time", /** In a snapshot Bundle, this key reports the number of received transactions from the binder driver before collection started. */ METRIC_KEY_PRE_RECEIVED_TRANSACTIONS : "pre_received_transactions", /** In a snapshot Bundle, this key reports the number of transactions sent by the running program before collection started. */ METRIC_KEY_PRE_SENT_TRANSACTIONS : "pre_sent_transactions", /** In a snapshot Bundle, this key reports the number of received transactions from the binder driver. */ METRIC_KEY_RECEIVED_TRANSACTIONS : "received_transactions", /** In a snapshot Bundle, this key reports the number of transactions sent by the running program. */ METRIC_KEY_SENT_TRANSACTIONS : "sent_transactions", /** In a snapshot Bundle, this key reports the number of garbage collection invocations. */ METRIC_KEY_GC_INVOCATION_COUNT : "gc_invocation_count", /** In a snapshot Bundle, this key reports the amount of allocated memory used by the running program. */ METRIC_KEY_JAVA_ALLOCATED : "java_allocated", /** In a snapshot Bundle, this key reports the amount of free memory available to the running program. */ METRIC_KEY_JAVA_FREE : "java_free", /** In a snapshot Bundle, this key reports the number of private dirty pages used by dalvik. */ METRIC_KEY_JAVA_PRIVATE_DIRTY : "java_private_dirty", /** In a snapshot Bundle, this key reports the proportional set size for dalvik. */ METRIC_KEY_JAVA_PSS : "java_pss", /** In a snapshot Bundle, this key reports the number of shared dirty pages used by dalvik. */ METRIC_KEY_JAVA_SHARED_DIRTY : "java_shared_dirty", /** In a snapshot Bundle, this key reports the total amount of memory available to the running program. */ METRIC_KEY_JAVA_SIZE : "java_size", /** In a snapshot Bundle, this key reports the amount of allocated memory in the native heap. */ METRIC_KEY_NATIVE_ALLOCATED : "native_allocated", /** In a snapshot Bundle, this key reports the amount of free memory in the native heap. */ METRIC_KEY_NATIVE_FREE : "native_free", /** In a snapshot Bundle, this key reports the number of private dirty pages used by the native heap. */ METRIC_KEY_NATIVE_PRIVATE_DIRTY : "native_private_dirty", /** In a snapshot Bundle, this key reports the proportional set size for the native heap. */ METRIC_KEY_NATIVE_PSS : "native_pss", /** In a snapshot Bundle, this key reports the number of shared dirty pages used by the native heap. */ METRIC_KEY_NATIVE_SHARED_DIRTY : "native_shared_dirty", /** In a snapshot Bundle, this key reports the size of the native heap. */ METRIC_KEY_NATIVE_SIZE : "native_size", /** In a snapshot Bundle, this key reports the number of objects allocated globally. */ METRIC_KEY_GLOBAL_ALLOC_COUNT : "global_alloc_count", /** In a snapshot Bundle, this key reports the size of all objects allocated globally. */ METRIC_KEY_GLOBAL_ALLOC_SIZE : "global_alloc_size", /** In a snapshot Bundle, this key reports the number of objects freed globally. */ METRIC_KEY_GLOBAL_FREED_COUNT : "global_freed_count", /** In a snapshot Bundle, this key reports the size of all objects freed globally. */ METRIC_KEY_GLOBAL_FREED_SIZE : "global_freed_size", /** In a snapshot Bundle, this key reports the number of private dirty pages used by everything else. */ METRIC_KEY_OTHER_PRIVATE_DIRTY : "other_private_dirty", /** In a snapshot Bundle, this key reports the proportional set size for everything else. */ METRIC_KEY_OTHER_PSS : "other_pss", /** In a snapshot Bundle, this key reports the number of shared dirty pages used by everything else. */ METRIC_KEY_OTHER_SHARED_DIRTY : "other_shared_dirty", /** */ setPerformanceResultsWriter : function( ) {}, /**Begin collection of memory usage information. @param {String} label description of code block between beginSnapshot and endSnapshot, used to label output */ beginSnapshot : function( ) {}, /**End collection of memory usage information. Returns collected data in a Bundle object. @return {Object {android.os.Bundle}} Memory and runtime metrics stored as key/value pairs. Values are of type long, and keys include: <ul> <li>{@link #METRIC_KEY_CPU_TIME cpu_time} <li>{@link #METRIC_KEY_EXECUTION_TIME execution_time} <li>{@link #METRIC_KEY_PRE_RECEIVED_TRANSACTIONS pre_received_transactions} <li>{@link #METRIC_KEY_PRE_SENT_TRANSACTIONS pre_sent_transactions} <li>{@link #METRIC_KEY_RECEIVED_TRANSACTIONS received_transactions} <li>{@link #METRIC_KEY_SENT_TRANSACTIONS sent_transactions} <li>{@link #METRIC_KEY_GC_INVOCATION_COUNT gc_invocation_count} <li>{@link #METRIC_KEY_JAVA_ALLOCATED java_allocated} <li>{@link #METRIC_KEY_JAVA_FREE java_free} <li>{@link #METRIC_KEY_JAVA_PRIVATE_DIRTY java_private_dirty} <li>{@link #METRIC_KEY_JAVA_PSS java_pss} <li>{@link #METRIC_KEY_JAVA_SHARED_DIRTY java_shared_dirty} <li>{@link #METRIC_KEY_JAVA_SIZE java_size} <li>{@link #METRIC_KEY_NATIVE_ALLOCATED native_allocated} <li>{@link #METRIC_KEY_NATIVE_FREE native_free} <li>{@link #METRIC_KEY_NATIVE_PRIVATE_DIRTY native_private_dirty} <li>{@link #METRIC_KEY_NATIVE_PSS native_pss} <li>{@link #METRIC_KEY_NATIVE_SHARED_DIRTY native_shared_dirty} <li>{@link #METRIC_KEY_NATIVE_SIZE native_size} <li>{@link #METRIC_KEY_GLOBAL_ALLOC_COUNT global_alloc_count} <li>{@link #METRIC_KEY_GLOBAL_ALLOC_SIZE global_alloc_size} <li>{@link #METRIC_KEY_GLOBAL_FREED_COUNT global_freed_count} <li>{@link #METRIC_KEY_GLOBAL_FREED_SIZE global_freed_size} <li>{@link #METRIC_KEY_OTHER_PRIVATE_DIRTY other_private_dirty} <li>{@link #METRIC_KEY_OTHER_PSS other_pss} <li>{@link #METRIC_KEY_OTHER_SHARED_DIRTY other_shared_dirty} </ul> */ endSnapshot : function( ) {}, /**Start measurement of user and cpu time. @param {String} label description of code block between startTiming and stopTiming, used to label output */ startTiming : function( ) {}, /**Add a measured segment, and start measuring the next segment. Returns collected data in a Bundle object. @param {String} label description of code block between startTiming and addIteration, and between two calls to addIteration, used to label output @return {Object {android.os.Bundle}} Runtime metrics stored as key/value pairs. Values are of type long, and keys include: <ul> <li>{@link #METRIC_KEY_LABEL label} <li>{@link #METRIC_KEY_CPU_TIME cpu_time} <li>{@link #METRIC_KEY_EXECUTION_TIME execution_time} </ul> */ addIteration : function( ) {}, /**Stop measurement of user and cpu time. @param {String} label description of code block between addIteration or startTiming and stopTiming, used to label output @return {Object {android.os.Bundle}} Runtime metrics stored in a bundle, including all iterations between calls to startTiming and stopTiming. List of iterations is keyed by {@link #METRIC_KEY_ITERATIONS iterations}. */ stopTiming : function( ) {}, /**Add an integer type measurement to the collector. @param {String} label short description of the metric that was measured @param {Number} value long value of the measurement */ addMeasurement : function( ) {}, /**Add a float type measurement to the collector. @param {String} label short description of the metric that was measured @param {Number} value float value of the measurement */ addMeasurement : function( ) {}, /**Add a string field to the collector. @param {String} label short description of the metric that was measured @param {String} value string summary of the measurement */ addMeasurement : function( ) {}, };