Created
February 6, 2020 07:35
-
-
Save kibotu/eb0f60b222be4b78eeebcc602f6e911a to your computer and use it in GitHub Desktop.
measureTime
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
inline fun <reified T> measureTime(message: String, min: Long? = null, block: () -> T): T { | |
val startTime = System.currentTimeMillis() | |
val result = block() | |
val blockRuntime = System.currentTimeMillis() - startTime | |
if (min != null) { | |
if (blockRuntime >= min) { | |
Logger.v("MeasureTime", "$message in ${blockRuntime}ms") | |
} | |
} else { | |
Logger.v("MeasureTime", "$message in ${blockRuntime}ms") | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment