Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-1278 RefreshRate is normalized to 0...60 #608

Merged
merged 3 commits into from
Sep 27, 2021

Conversation

buranmert
Copy link
Contributor

What and why?

RefreshRate is shown as a mobile vital in Datadog UI.
It needs to be normalized as different devices can have different maximum FPS rates.

How?

It was normalized to 0...1, this was not consistent with other platforms.
Now it is normalized to 0...60 range, as browser and Android SDKs do.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference

@buranmert buranmert self-assigned this Sep 24, 2021
@buranmert buranmert requested a review from a team as a code owner September 24, 2021 13:58
Copy link
Member

@xgouchet xgouchet left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -39,7 +39,7 @@ class VitalInfoSamplerTests: XCTestCase {
XCTAssertEqual(sampler.memory.meanValue, 321.0)
XCTAssertGreaterThan(sampler.memory.sampleCount, 1)
let maxFPS = Double(UIScreen.main.maximumFramesPerSecond)
XCTAssertEqual(sampler.refreshRate.meanValue, 666.0 / maxFPS)
Copy link
Member

Choose a reason for hiding this comment

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

You could have left the 666 value and then used:

XCTAssertEqual(sampler.refreshRate.meanValue, (666.0 / maxFPS) * 60.0)

@buranmert buranmert force-pushed the buranmert/RUMM-1278-fix-refresh-rate-scale branch from 9784a51 to b1437d5 Compare September 24, 2021 14:07
@@ -39,7 +39,7 @@ internal final class VitalInfoSampler {

var refreshRate: VitalInfo {
let info = refreshRatePublisher.currentValue
return info.scaledDown(by: maximumRefreshRate)
return info.scaledDown(by: maximumRefreshRate / 60.0)
Copy link
Member

Choose a reason for hiding this comment

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

How about defining a constant and adding a comment on normalization? I'm afraid that this might become forgotten and unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment added to the line above

NOTE: refreshRate is normalized to 0...60 range, assuming 60 is the industry standard.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with using a constant value for this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can't come up with a local variable name which doesn't make things more confusing 🤔
any suggestions?

Copy link
Member

@ncreated ncreated Sep 24, 2021

Choose a reason for hiding this comment

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

struct Constants {
    // We use normalized 0...60 range for refresh rate in Mobile Vitals,
    // assuming 60 is the industry standard.
    static let normalizedRefreshRate = 60
}

Is +/- what we do in other places.

Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

🙌

@buranmert buranmert merged commit 818ed4c into master Sep 27, 2021
@buranmert buranmert deleted the buranmert/RUMM-1278-fix-refresh-rate-scale branch September 27, 2021 09:00
@ncreated ncreated mentioned this pull request Sep 28, 2021
2 tasks
ncreated pushed a commit that referenced this pull request Oct 4, 2021
…rate-scale

RUMM-1278 RefreshRate is normalized to 0...60

(cherry picked from commit 818ed4c)
@ncreated ncreated mentioned this pull request Oct 4, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants