API reference
API reference
Select your platform
No SDKs available
No versions available

TraceUtils

TraceUtils

object TraceUtils
TraceUtils are used to perform traces on code and do performance optimization. You can utilize Perfetto to analyze the traces.
forceEnabled is set to false by default. If you want to enable tracing, set it to true.
Example usage:
TraceUtils.forceEnabled = true
TraceUtils.trace("myTrace") {
  // do something
}

Properties

NameSummary
cookie
var cookie: Int
forceEnabled
var forceEnabled: Boolean

Functions

NameSummary
beginAsyncSection
fun beginAsyncSection(sectionName: String): Int

Begin an async trace section. You will need to call endAsyncSection() to end the current trace section.
beginSection
fun beginSection(sectionName: String)

Begin a trace section. You will need to call endSection() to end the current trace section. You can nest trace sections.
endAsyncSection
fun endAsyncSection(sectionName: String, id: Int)

End an async trace section. Make sure you have called a beginAsyncSection() before calling this with the same id.
endSection
fun endSection()

End the current trace section. Make sure you have called a beginSection() before calling this. You are responsible for managing your trace sections.
trace
inline fun trace(sectionName: String, block: () -> Unit)

This method is a convenience method that handles the beginSection() and endSection() for you. It will run the block of code within the trace section.
traceAsync
inline fun traceAsync(sectionName: String, block: () -> Unit)

This method is a convenience method that handles the beginAsyncSection() and endAsyncSection() for you. It will run the block of code within the trace section.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon