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

fix: speed up getNodeFromTree #1302

Merged
merged 4 commits into from
Jan 9, 2019
Merged

Conversation

paulirish
Copy link
Contributor

@paulirish paulirish commented Jan 4, 2019

axe.utils.getNodeFromTree currently doesn't return early if it has found a result. It continues iterating through the rest of the children. But the perf win is pretty huge: ~600ms on the page I'm testing.

To test I ran axe against this URL like this:

await window.axe.run(document, {performanceTimer:true, elementRef: true,runOnly: {  type: 'tag',  values: ['wcag2a', 'wcag2aa']},resultTypes: ['violations', 'inapplicable'],});

And then I looked at the Measure runchecks_color-contrast took XXXX ms line. (As that rule uses this method quite a lot).

numbers:

develop this branch
3126 2351
3004 2399
2846 2360

image

On average, a 620ms improvement in this one rule.

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: @WilcoFiers

@paulirish paulirish requested a review from a team as a code owner January 4, 2019 00:20
if (candidate.actualNode === node) {
if (found) {
return;
} else if (candidate.actualNode === node) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: can remove this else since we return from the condition above.

@WilcoFiers
Copy link
Contributor

Fantastic! Thanks for the contribution @paulirish!

@WilcoFiers WilcoFiers merged commit 5f834ed into dequelabs:develop Jan 9, 2019
@paulirish paulirish deleted the found branch April 17, 2019 16:06
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.

3 participants