Created
December 8, 2023 14:15
-
-
Save adil-hussain-84/87d278136fe56babcc9dd209d3974102 to your computer and use it in GitHub Desktop.
Android class that helps log the number of milliseconds that have elapsed since a reference point.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElapsedTimeLogger(private val tag: String = ElapsedTimeLogger::class.simpleName!!) { | |
private var startTime = SystemClock.elapsedRealtime() | |
/** | |
* Logs the number of milliseconds that have elapsed since this [ElapsedTimeLogger] was initialised. | |
* | |
* The logs are sent to log output (i.e. Logcat) as a debug message. | |
*/ | |
fun logElapsedTime() { | |
val currentTime = SystemClock.elapsedRealtime() | |
val elapsedTime = currentTime - startTime | |
Log.d(tag, "Elapsed time in milliseconds = $elapsedTime") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment