A lightweight Android SDK for monitoring real-time app performance metrics.
Track critical performance indicators such as:
- 🚀 App Start Time (Cold & Warm)
- 🎞 Frame Drops (UI Jank Detection)
- ⏳ ANR Detection (Main Thread Blocking)
- 🧠 Memory Usage Monitoring
- 🌐 Network Latency Tracking
All metrics are exposed through a single, unified callback API.
https://github.com/hrkdevkits/Performance-Monitoring
| Feature | Description |
|---|---|
| App start time | Cold/warm start duration from process start to first frame |
| Frame drops | Detects frames longer than one vsync interval (e.g. 60fps) |
| ANR detection | Detects main thread blocked longer than a configurable threshold |
| Memory usage | Periodic Java heap usage samples |
| Network latency | Request start/end tracking for latency and status |
./gradlew :performance-sdk:publishToMavenLocalsettings.gradle.kts — add Maven Local so Gradle can resolve the SDK:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal() // for com.hrkdevkits:performance-monitoring
}
}app/build.gradle.kts — add the dependency:
dependencies {
implementation("com.hrkdevkits:performance-monitoring:1.0.0")
}Requirements: minSdk 21+, Kotlin 1.9+, Android Gradle Plugin 8.x.
- In your Application class, call
PerformanceSDK.startMonitoring()with a callback:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
PerformanceSDK.startMonitoring(this, object : PerformanceCallback {
override fun onAppStart(appStartMetrics: AppStartMetrics) {
// Log or send to your backend
}
override fun onFrameDrop(frameDropMetrics: FrameDropMetrics) { }
override fun onANR(anrMetrics: ANRMetrics) { }
override fun onMemorySample(memoryMetrics: MemoryMetrics) { }
override fun onNetworkRequest(networkMetrics: NetworkMetrics) { }
})
}
}- Network latency is reported when you record requests:
// Option A: record full request when it completes
val startMs = System.currentTimeMillis()
// ... perform request ...
PerformanceSDK.recordNetworkRequest(url, "GET", startMs, responseCode)
// Option B: start/end
val requestId = PerformanceSDK.recordNetworkRequestStart(url, "GET")
// ... perform request ...
PerformanceSDK.recordNetworkRequestEnd(requestId, responseCode)- (Optional) Use custom config:
PerformanceSDK.startMonitoring(
this,
callback,
PerformanceSDK.Config(
expectedFrameMs = 17L, // 60fps
anrThresholdMs = 5000L, // 5 seconds
memorySampleIntervalMs = 30_000L
)
)| Method | Description |
|---|---|
startMonitoring(application, callback, config?) |
Start all monitoring; call from Application.onCreate. |
stopMonitoring() |
Stop monitoring and release resources. |
recordNetworkRequest(url, method, startTimeMs, statusCode) |
Record a completed network request. |
recordNetworkRequestStart(url, method) |
Start tracking a request; returns id for recordNetworkRequestEnd. |
recordNetworkRequestEnd(requestId, statusCode) |
End tracking and report latency. |
isMonitoring() |
Returns whether monitoring is active. |
All methods have default empty implementations; override only what you need.
onAppStart(AppStartMetrics)– cold/warm start timeonFrameDrop(FrameDropMetrics)– slow frame duration and dropped frame countonANR(ANRMetrics)– block duration and main thread stack traceonMemorySample(MemoryMetrics)– heap usage (used, max, free, %)onNetworkRequest(NetworkMetrics)– URL, method, latency, status code
