Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/util/TimingLogger#pubctors) \| [Methods](https://developer.android.com/reference/android/util/TimingLogger#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/util/TimingLogger#inhmethods)

# TimingLogger

*** ** * ** ***

` public class TimingLogger `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.util.TimingLogger |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 30.**   

Use `https://developer.android.com/reference/android/os/Trace`, or [Android Studio](https://developer.android.com/studio/profile/benchmark). In general, milliseconds is the wrong granularity for method-level tracing. Rounding errors can overemphasize cheap operations, or underemphasize repeated operations. This timing system also does not take CPU scheduling or frequency into account.

A utility class to help log timings splits throughout a method call. Typical usage is:

```
    TimingLogger timings = new TimingLogger(TAG, "methodA");
    // ... do some work A ...
    timings.addSplit("work A");
    // ... do some work B ...
    timings.addSplit("work B");
    // ... do some work C ...
    timings.addSplit("work C");
    timings.dumpToLog();
```

The dumpToLog call would add the following to the log:

```
    D/TAG     ( 3459): methodA: begin
    D/TAG     ( 3459): methodA:      9 ms, work A
    D/TAG     ( 3459): methodA:      1 ms, work B
    D/TAG     ( 3459): methodA:      6 ms, work C
    D/TAG     ( 3459): methodA: end, 16 ms
```

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/util/TimingLogger#TimingLogger(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String tag, https://developer.android.com/reference/java/lang/String label) ` Create and initialize a TimingLogger object that will log using the specific tag. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/util/TimingLogger#addSplit(java.lang.String)(https://developer.android.com/reference/java/lang/String splitLabel) ` Add a split for the current time, labeled with splitLabel. |
| ` void` | ` https://developer.android.com/reference/android/util/TimingLogger#dumpToLog()() ` Dumps the timings to the log using Log.d(). |
| ` void` | ` https://developer.android.com/reference/android/util/TimingLogger#reset()() ` Clear and initialize a TimingLogger object that will log using the tag and label that was specified previously, either via the constructor or a call to reset(tag, label). |
| ` void` | ` https://developer.android.com/reference/android/util/TimingLogger#reset(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String tag, https://developer.android.com/reference/java/lang/String label) ` Clear and initialize a TimingLogger object that will log using the specific tag. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### TimingLogger

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

```
public TimingLogger (String tag, 
                String label)
```

Create and initialize a TimingLogger object that will log using the specific tag. If the Log.isLoggable is not enabled to at least the Log.VERBOSE level for that tag at creation time then the addSplit and dumpToLog call will do nothing.

<br />

| Parameters ||
|---|---|
| `tag` | `String`: the log tag to use while logging the timings <br /> |
| `label` | `String`: a string to be displayed with each log <br /> |

## Public methods

### addSplit

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

```
public void addSplit (String splitLabel)
```

Add a split for the current time, labeled with splitLabel. If Log.isLoggable was not enabled to at least the Log.VERBOSE for the specified tag at construction or reset() time then this call does nothing.

<br />

| Parameters ||
|---|---|
| `splitLabel` | `String`: a label to associate with this split. <br /> |

### dumpToLog

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

```
public void dumpToLog ()
```

Dumps the timings to the log using Log.d(). If Log.isLoggable was not enabled to at least the Log.VERBOSE for the specified tag at construction or reset() time then this call does nothing.

<br />

### reset

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

```
public void reset ()
```

Clear and initialize a TimingLogger object that will log using the tag and label that was specified previously, either via the constructor or a call to reset(tag, label). If the Log.isLoggable is not enabled to at least the Log.VERBOSE level for that tag at creation time then the addSplit and dumpToLog call will do nothing.

<br />

### reset

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

```
public void reset (String tag, 
                String label)
```

Clear and initialize a TimingLogger object that will log using the specific tag. If the Log.isLoggable is not enabled to at least the Log.VERBOSE level for that tag at creation time then the addSplit and dumpToLog call will do nothing.

<br />

| Parameters ||
|---|---|
| `tag` | `String`: the log tag to use while logging the timings <br /> |
| `label` | `String`: a string to be displayed with each log <br /> |