Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# InstructionCount

*** ** * ** ***

```
class InstructionCount
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.os.Debug.InstructionCount](https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#) |

*** ** * ** ***

> [!CAUTION]
> **This class was deprecated in API level 23.**
>
> Instruction counting is no longer supported.

API for gathering and querying instruction counts. Example usage:

```kotlin
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());
    }
  
```

<br />

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#InstructionCount()()` <br /> |

| Public methods ||
|---|---|
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#collect()()` Collect instruction counts. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#globalMethodInvocations()()` Return the total number of method-invocation instructions executed globally. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#globalTotal()()` Return the total number of instructions executed globally (i.e. in all threads). |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/os/Debug.InstructionCount#resetAndStart()()` Reset counters and ensure counts are running. |

## Public constructors

### InstructionCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
InstructionCount()
```

## Public methods

### collect

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun collect(): Boolean
```

**Deprecated:** *Deprecated in Java.*

Collect instruction counts. May or may not stop the counting process.

### globalMethodInvocations

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun globalMethodInvocations(): Int
```

**Deprecated:** *Deprecated in Java.*

Return the total number of method-invocation instructions executed globally.

### globalTotal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun globalTotal(): Int
```

**Deprecated:** *Deprecated in Java.*

Return the total number of instructions executed globally (i.e. in all threads).

### resetAndStart

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun resetAndStart(): Boolean
```

**Deprecated:** *Deprecated in Java.*

Reset counters and ensure counts are running. Counts may have already been running.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | true if counting was started |