Skip to content

Commit

Permalink
Clean-up logging API
Browse files Browse the repository at this point in the history
Summary:
1. Rename Event field to duratioNs - usually time is measure in ms, and it required extra chasing down the code implementation to understand if we're using ns or ms.
2. No need to override the method, as default implementation already does that - https://www.internalfb.com/code/fbsource/fbandroid/java/com/facebook/quicklog/QuickPerformanceLoggerImpl.java?lines=2627-2627. In addition, the timeunit value is ignored when that Autoset flag is used (and it is different from what this code sets), which brings confusion to what time units are actually used.

Reviewed By: astreet

Differential Revision: D57778937

fbshipit-source-id: 8edef9746277dfe601256d5a84dca0575a414fbb
  • Loading branch information
Kata Zavor authored and facebook-github-bot committed May 25, 2024
1 parent f853e83 commit 0ad7883
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class DebugMarkerEvent(
/** Base class for process events */
class DebugProcessEvent(
val timestamp: Long = System.currentTimeMillis(), // for calendar time
val duration: Duration,
val durationNs: Duration,
type: String,
renderStateId: String,
threadName: String = Thread.currentThread().name,
Expand All @@ -149,7 +149,7 @@ class DebugProcessEvent(
attributes =
buildMap {
put(DebugEventAttribute.Timestamp, timestamp)
put(DebugEventAttribute.Duration, duration)
put(DebugEventAttribute.Duration, durationNs)
putAll(attributes)
})

Expand Down Expand Up @@ -320,7 +320,6 @@ object DebugEventDispatcher {

@JvmStatic
fun endTrace(traceIdentifier: Int) {
val endTime = System.nanoTime()
val last = traceIdsToEvents.remove(traceIdentifier) ?: return
val type = last.type

Expand All @@ -338,12 +337,13 @@ object DebugEventDispatcher {
return
}

val endTime = System.nanoTime()
val event =
DebugProcessEvent(
type = type,
timestamp = last.timestamp, // for calender time
renderStateId = last.renderStateId,
duration = Duration(value = endTime - last.startTime),
durationNs = Duration(value = endTime - last.startTime),
attributes = last.attributes,
)

Expand Down Expand Up @@ -390,7 +390,7 @@ object DebugEventDispatcher {
type = type,
timestamp = timestamp,
renderStateId = renderStateId(),
duration = Duration(value = endTime - startTime),
durationNs = Duration(value = endTime - startTime),
attributes = attributes,
)

Expand Down

0 comments on commit 0ad7883

Please sign in to comment.