-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||
| package io.radar.sdk | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import java.util.Date | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| class RadarTelemetry { | ||||||||||||||||||||||||||||||||||||||||||
| private val startTimes: MutableMap<String, Long> = mutableMapOf() | ||||||||||||||||||||||||||||||||||||||||||
| private val endTimes: MutableMap<String, Long> = mutableMapOf() | ||||||||||||||||||||||||||||||||||||||||||
| fun start(tag: String = "") { | ||||||||||||||||||||||||||||||||||||||||||
| startTimes[tag] = Date().time | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| fun end(tag: String = "") { | ||||||||||||||||||||||||||||||||||||||||||
| if (startTimes.containsKey(tag)) { | ||||||||||||||||||||||||||||||||||||||||||
| endTimes[tag] = Date().time | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| 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() |
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() |
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 | |
| } |
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.