Skip to content

Commit

Permalink
Improve FpsDebugFrameCallback.getTotalTimeMS accuracy (#46869)
Browse files Browse the repository at this point in the history
Summary:
`FpsDebugFrameCallback.getTotalTimeMS()` implementation loses accuracy due to incorrect order of type casting to int

## Changelog:

[ANDROID] [CHANGED] - Improve FpsDebugFrameCallback.getTotalTimeMS() accuracy

Pull Request resolved: #46869

Test Plan:
- Launch some test app
- Open up the [Dev Menu](https://reactnative.dev/docs/debugging#accessing-the-dev-menu) in your app and toggle Show Perf Monitor
- Compare results of current & improved implementations

Reviewed By: rshest

Differential Revision: D64024054

Pulled By: arushikesarwani94

fbshipit-source-id: 438792bace0e3443d151cf13364f6e94b66dfb5e
  • Loading branch information
aamagda authored and facebook-github-bot committed Oct 8, 2024
1 parent 19fc1c7 commit d54c25f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public class FpsDebugFrameCallback(private val reactContext: ReactContext) :
public fun get4PlusFrameStutters(): Int = fourPlusFrameStutters

public val totalTimeMS: Int
get() = (lastFrameTime.toDouble() - firstFrameTime).toInt() / 1000000
get() = ((lastFrameTime.toDouble() - firstFrameTime) / 1000000.0).toInt()

/**
* Returns the FpsInfo as if stop had been called at the given upToTimeMs. Only valid if
Expand Down

0 comments on commit d54c25f

Please sign in to comment.