Stay organized with collections
Save and categorize content based on your preferences.
InstructionCount
class InstructionCount
API for gathering and querying instruction counts. Example usage:
Debug.InstructionCount icount = new Debug.InstructionCount();
icount.resetAndStart();
[... do lots of stuff ...]
if (icount.collect()) {
System.out.println("Total instructions executed: "
+ icount.globalTotal());
System.out.println("Method invocations: "
+ icount.globalMethodInvocations());
}
Summary
Public methods |
open Boolean |
Collect instruction counts.
|
open Int |
Return the total number of method-invocation instructions executed globally.
|
open Int |
Return the total number of instructions executed globally (i.e. in all threads).
|
open Boolean |
Reset counters and ensure counts are running.
|
Public constructors
InstructionCount
InstructionCount()
Public methods
collect
open fun collect(): Boolean
Deprecated: Deprecated in Java.
Collect instruction counts. May or may not stop the counting process.
globalMethodInvocations
open fun globalMethodInvocations(): Int
Deprecated: Deprecated in Java.
Return the total number of method-invocation instructions executed globally.
globalTotal
open fun globalTotal(): Int
Deprecated: Deprecated in Java.
Return the total number of instructions executed globally (i.e. in all threads).
resetAndStart
open fun resetAndStart(): Boolean
Deprecated: Deprecated in Java.
Reset counters and ensure counts are running. Counts may have already been running.
Return |
Boolean |
true if counting was started |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Debug.InstructionCount\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nInstructionCount\n================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/Debug.InstructionCount \"View this page in Java\") \n\n```\nclass InstructionCount\n```\n\n|---|----------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.os.Debug.InstructionCount](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 23.**\n|\n| Instruction counting is no longer supported.\n\nAPI for gathering and querying instruction counts. Example usage: \n\n```kotlin\nDebug.InstructionCount icount = new Debug.InstructionCount();\n icount.resetAndStart();\n [... do lots of stuff ...]\n if (icount.collect()) {\n System.out.println(\"Total instructions executed: \"\n + icount.globalTotal());\n System.out.println(\"Method invocations: \"\n + icount.globalMethodInvocations());\n }\n \n```\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------|---|\n| [InstructionCount](#InstructionCount())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [collect](#collect())`()` Collect instruction counts. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [globalMethodInvocations](#globalMethodInvocations())`()` Return the total number of method-invocation instructions executed globally. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [globalTotal](#globalTotal())`()` Return the total number of instructions executed globally (i.e. in all threads). |\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [resetAndStart](#resetAndStart())`()` Reset counters and ensure counts are running. |\n\nPublic constructors\n-------------------\n\n### InstructionCount\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nInstructionCount()\n```\n\nPublic methods\n--------------\n\n### collect\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun collect(): Boolean\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nCollect instruction counts. May or may not stop the counting process. \n\n### globalMethodInvocations\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun globalMethodInvocations(): Int\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReturn the total number of method-invocation instructions executed globally. \n\n### globalTotal\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun globalTotal(): Int\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReturn the total number of instructions executed globally (i.e. in all threads). \n\n### resetAndStart\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun resetAndStart(): Boolean\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReset counters and ensure counts are running. Counts may have already been running.\n\n| Return ||\n|------------------------------------------------------------------------------------|------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if counting was started |"]]