Created
July 21, 2019 17:20
-
-
Save ZahidRasheed/73af9587f3ef646b168ca0137bf2b261 to your computer and use it in GitHub Desktop.
Measure time
This file contains hidden or 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
inline fun <T> measureTimeMillis(loggingFunction: (Long) -> Unit, | |
function: () -> T): T { | |
val startTime = System.currentTimeMillis() | |
val result: T = function.invoke() | |
loggingFunction.invoke(System.currentTimeMillis() - startTime) | |
return result | |
} | |
val file: File = | |
measureTimeMillis({ time -> Log.d(TAG, "Read and decode took $time") }) { | |
readAndDecodeFile() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment