From 521a41d81be0519e80c11accaac0870f17fc0a0f Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 30 Jul 2025 17:50:21 -0400 Subject: [PATCH] avoids logging with sub ms times --- .../src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt index eafafe292..7d3d0719b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt @@ -152,7 +152,7 @@ fun debugState(context: Context) { inline fun logTime( debugMessage: String, - minToReportMs: Int = 0, + minToReportMs: Int = 1, block: () -> T, ): T = if (isDebug) { @@ -167,11 +167,14 @@ inline fun logTime( inline fun 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()