Skip to content

Instantly share code, notes, and snippets.

@Sloy
Created July 9, 2020 12:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sloy/6692ed645701f5316073e0e3bf7f37fd to your computer and use it in GitHub Desktop.
Save Sloy/6692ed645701f5316073e0e3bf7f37fd to your computer and use it in GitHub Desktop.
import com.google.firebase.perf.FirebasePerformance
object FirebasePerformanceWrapper {
fun <T> trace(name: String, block: () -> T): T {
val trace = runCatching { FirebasePerformance.getInstance().newTrace(name) }.getOrNull()
trace?.start()
val result = block()
trace?.stop()
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment