Tracing Action Response Times!
This library is not stable for usage beyond Square, the APIs and internals might change anytime.
Tart... ?
Add the tart
dependency to your library or app's build.gradle
file:
dependencies {
implementation 'com.squareup.tart:tart:0.1'
}
Then add a new AppLaunch.onAppLaunchListeners
. See AppLaunch
javadoc for details.
import android.app.Application
import tart.AppLaunch
import tart.PreLaunchState
class ExampleApplication : Application() {
override fun onCreate() {
super.onCreate()
AppLaunch.onAppLaunchListeners += { appLaunch ->
val startType = when (appLaunch.preLaunchState) {
PreLaunchState.NO_PROCESS -> "cold start"
PreLaunchState.NO_PROCESS_FIRST_LAUNCH_AFTER_INSTALL -> "cold start"
PreLaunchState.NO_PROCESS_FIRST_LAUNCH_AFTER_UPGRADE -> "cold start"
PreLaunchState.PROCESS_WAS_LAUNCHING_IN_BACKGROUND -> "warm start"
PreLaunchState.NO_ACTIVITY_NO_SAVED_STATE -> "warm start"
PreLaunchState.NO_ACTIVITY_BUT_SAVED_STATE -> "warm start"
PreLaunchState.ACTIVITY_WAS_STOPPED -> "hot start"
}
val durationMillis = appLaunch.duration.uptimeMillis
println("$startType launch: $durationMillis ms")
}
}
}
Copyright 2021 Square Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.