Skip to content

RUMM-2687 Invert frame time to get js refresh rate#1105

Merged
louiszawadzki merged 2 commits into
developfrom
louiszawadzki/rumm-2687/report-harmonic-mean-of-js-refresh-rate
Oct 26, 2022
Merged

RUMM-2687 Invert frame time to get js refresh rate#1105
louiszawadzki merged 2 commits into
developfrom
louiszawadzki/rumm-2687/report-harmonic-mean-of-js-refresh-rate

Conversation

@louiszawadzki

Copy link
Copy Markdown
Contributor

What does this PR do?

Let the RN SDK report the frame time, then invert it when reporting to backend to report frame rate.

Motivation

Get a more sensible for the average js refresh rate by getting the harmonic mean instead of the arithmetic mean.
See https://gamedev.net/forums/topic/628085-math-fail-adding-frames-per-second/4960225/ and https://en.wikipedia.org/wiki/Harmonic_mean#Average_speed to understand why this makes more sense.

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@louiszawadzki
louiszawadzki requested a review from a team as a code owner October 25, 2022 12:51

private fun VitalInfo.toInversePerformanceMetric(): ViewEvent.FlutterBuildTime {
return ViewEvent.FlutterBuildTime(
min = invertValue(maxValue),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you switching min with max here ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment to explain that would be nice here. It will be very hard to remember why we are doing this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment indeed.
If we take the inverse of numbers, min and max are reversed.

For instance if min = 4 and max = 10, then for the inverse min = 1/max = 0.1 and max = 1/min = 0.25

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got that...what is hard for me to understand is that right now we are inverting the max value to create the min. But is this relevant ?

@codecov-commenter

codecov-commenter commented Oct 25, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1105 (79c3f51) into develop (8f67c98) will decrease coverage by 0.03%.
The diff coverage is 87.50%.

@@             Coverage Diff             @@
##           develop    #1105      +/-   ##
===========================================
- Coverage    83.29%   83.25%   -0.03%     
===========================================
  Files          273      273              
  Lines         9363     9368       +5     
  Branches      1503     1504       +1     
===========================================
+ Hits          7798     7799       +1     
- Misses        1147     1149       +2     
- Partials       418      420       +2     
Impacted Files Coverage Δ
.../android/rum/internal/domain/scope/RumViewScope.kt 96.69% <85.71%> (-0.17%) ⬇️
...in/com/datadog/android/rum/RumPerformanceMetric.kt 100.00% <100.00%> (ø)
...ndroid/core/internal/persistence/file/EventMeta.kt 80.00% <0.00%> (-10.00%) ⬇️
...android/rum/internal/ndk/DatadogNdkCrashHandler.kt 87.57% <0.00%> (-1.08%) ⬇️
.../android/rum/internal/monitor/DatadogRumMonitor.kt 92.05% <0.00%> (-0.57%) ⬇️
...rc/main/java/com/datadog/opentracing/DDTracer.java 55.65% <0.00%> (-0.42%) ⬇️
...droid/rum/tracking/FragmentViewTrackingStrategy.kt 86.96% <0.00%> (+4.35%) ⬆️
...m/datadog/android/core/internal/utils/ViewUtils.kt 81.82% <0.00%> (+9.09%) ⬆️

@louiszawadzki
louiszawadzki force-pushed the louiszawadzki/rumm-2687/report-harmonic-mean-of-js-refresh-rate branch from 5191821 to bc37e69 Compare October 25, 2022 16:21
@louiszawadzki
louiszawadzki force-pushed the louiszawadzki/rumm-2687/report-harmonic-mean-of-js-refresh-rate branch from c0402b7 to 79c3f51 Compare October 26, 2022 12:30
@louiszawadzki
louiszawadzki merged commit 0239ec1 into develop Oct 26, 2022
@louiszawadzki
louiszawadzki deleted the louiszawadzki/rumm-2687/report-harmonic-mean-of-js-refresh-rate branch October 26, 2022 12:52
@xgouchet xgouchet added this to the 1.15.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants