-
Notifications
You must be signed in to change notification settings - Fork 27
Sdk profiler #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Sdk profiler #423
Conversation
507631d to
ae2eb42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a profiling/telemetry system to the Radar SDK to measure execution times of various operations during location tracking.
- Adds a new
RadarTelemetryclass for timing operations - Integrates telemetry timing calls throughout the verification tracking flow
- Updates imports to be more explicit rather than using wildcard imports
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| RadarTelemetry.kt | New telemetry class that tracks start/end times for operations and formats timing data |
| RadarVerificationManager.kt | Adds telemetry timing to track verification flow stages including config retrieval, location getting, integrity tokens, and API calls |
| Radar.kt | Integrates telemetry into the trackOnce method and replaces wildcard imports with explicit imports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| fun formatted(): String { | ||
| return endTimes.map { (tag, endTime) -> | ||
| val diff = endTime - startTimes[tag]!! | ||
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force unwrapping with !! could cause a crash if endTimes contains a tag that's not in startTimes. This could happen if end() is called without a corresponding start() call. Consider using safe access or validation.
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" | |
| return endTimes.mapNotNull { (tag, endTime) -> | |
| val startTime = startTimes[tag] | |
| if (startTime != null) { | |
| val diff = endTime - startTime | |
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" | |
| } else { | |
| null | |
| } |
|
|
||
| fun end(tag: String = "") { | ||
| if (startTimes.containsKey(tag)) { | ||
| endTimes[tag] = Date().time |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Date().time creates unnecessary Date objects. Consider using System.currentTimeMillis() which is more efficient for timing measurements.
| endTimes[tag] = Date().time | |
| class RadarTelemetry { | |
| private val startTimes: MutableMap<String, Long> = mutableMapOf() | |
| private val endTimes: MutableMap<String, Long> = mutableMapOf() | |
| fun start(tag: String = "") { | |
| startTimes[tag] = System.currentTimeMillis() | |
| } | |
| fun end(tag: String = "") { | |
| if (startTimes.containsKey(tag)) { | |
| endTimes[tag] = System.currentTimeMillis() |
|
|
||
| fun end(tag: String = "") { | ||
| if (startTimes.containsKey(tag)) { | ||
| endTimes[tag] = Date().time |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Date().time creates unnecessary Date objects. Consider using System.currentTimeMillis() which is more efficient for timing measurements.
| endTimes[tag] = Date().time | |
| startTimes[tag] = System.currentTimeMillis() | |
| } | |
| fun end(tag: String = "") { | |
| if (startTimes.containsKey(tag)) { | |
| endTimes[tag] = System.currentTimeMillis() |
| package io.radar.sdk | ||
|
|
||
| import java.util.Date | ||
|
|
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public class lacks documentation. Consider adding KDoc to explain the purpose and usage of this telemetry class.
| /** | |
| * RadarTelemetry provides simple timing utilities for measuring the duration of code execution. | |
| * | |
| * Usage: | |
| * - Call [start] with an optional tag to begin timing. | |
| * - Call [end] with the same tag to end timing. | |
| * - Use [get] to retrieve the elapsed time in milliseconds for a tag. | |
| * - Use [formatted] to get a human-readable summary of all timings. | |
| * | |
| * This class is useful for performance monitoring and debugging. | |
| */ |
No description provided.