avoids logging with sub ms times

This commit is contained in:
Vitor Pamplona
2025-07-30 17:50:21 -04:00
parent c6e103ff87
commit 521a41d81b
@@ -152,7 +152,7 @@ fun debugState(context: Context) {
inline fun <T> logTime(
debugMessage: String,
minToReportMs: Int = 0,
minToReportMs: Int = 1,
block: () -> T,
): T =
if (isDebug) {
@@ -167,11 +167,14 @@ inline fun <T> logTime(
inline fun <T> logTime(
debugMessage: (T) -> String,
minToReportMs: Int = 1,
block: () -> T,
): T =
if (isDebug) {
val (result, elapsed) = measureTimedValue(block)
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}")
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}")
}
result
} else {
block()