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

Implement performance ticks for framerate. #1420

Merged
merged 1 commit into from Jan 16, 2016

Conversation

cramforce
Copy link
Member

Calculates the rate by counting animation frames over a timespan.
We only measure when we rendered an element or the user scrolled, and then for 5 seconds. This is basically a heuristic for "something interesting might be happening". Otherwise on mostly empty pages the framerate is always 60fps.

this.collect();
console.info('visible')
} else {
this.win.cancelAnimationFrame(this.requestedFrame_);
Copy link
Contributor

Choose a reason for hiding this comment

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

if (this.win.cancelAnimationFrame) {...}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

this.requestedFrame_ can also be null here. Not sure if that would be a problem here.

@dvoytenko
Copy link
Contributor

Looks good. I think just couple of reset conditions need fixing.

* to avoid having to request and cancel all the time.
* @private {boolean}
*/
this.frameScheduled_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just use this.requestedFrame_ != null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

@cramforce
Copy link
Member Author

This is now ready for review.

@dvoytenko
Copy link
Contributor

LGTM on my side. Leaving final LGTM to @erwinmombay

this.reset_();
this.collect();
} else {
this.reset_();
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the else conditional. Always #reset_, and call #collect if isActive_.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed :)

@erwinmombay
Copy link
Member

@cramforce LGTM, pending @jridgewell recommendation

Calculates the rate by counting animation frames over a timespan.
We only measure when we rendered an element or the user scrolled, and then for 5 seconds. This is basically a heuristic for "something interesting might be happening". Otherwise on mostly empty pages the framerate is always 60fps.
cramforce added a commit that referenced this pull request Jan 16, 2016
Implement performance ticks for framerate.
@cramforce cramforce merged commit 387b0b5 into ampproject:master Jan 16, 2016
@cramforce cramforce deleted the framerate branch January 16, 2016 03:08
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.

None yet

4 participants