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(perf): update end mark for rules #1303

Merged
merged 2 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,8 @@ function getRulesToRun(rules, context, options) {
*/
function getDefferedRule(rule, context, options) {
// init performance timer of requested via options
let markStart;
let markEnd;
if (options.performanceTimer) {
markStart = 'mark_rule_start_' + rule.id;
markEnd = 'mark_rule_end_' + rule.id;
// mark start
axe.utils.performanceTimer.mark(markStart);
axe.utils.performanceTimer.mark('mark_rule_start_' + rule.id);
}

return (resolve, reject) => {
Expand All @@ -384,15 +379,6 @@ function getDefferedRule(rule, context, options) {
options,
// resolve callback for rule `run`
ruleResult => {
// if performance timer - mark end & measure
if (options.performanceTimer) {
axe.utils.performanceTimer.mark(markEnd);
axe.utils.performanceTimer.measure(
'rule_' + rule.id,
markStart,
markEnd
);
}
// resolve
resolve(ruleResult);
},
Expand Down
15 changes: 10 additions & 5 deletions lib/core/base/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ Rule.prototype.run = function(context, options, resolve, reject) {

const q = axe.utils.queue();
const ruleResult = new RuleResult(this);
const markStart = 'mark_runchecks_start_' + this.id;
const markEnd = 'mark_runchecks_end_' + this.id;
const markStart = 'mark_rule_start_' + this.id;
const markEnd = 'mark_rule_end_' + this.id;
const markChecksStart = 'mark_runchecks_start_' + this.id;
const markChecksEnd = 'mark_runchecks_end_' + this.id;

let nodes;

Expand All @@ -169,7 +171,7 @@ Rule.prototype.run = function(context, options, resolve, reject) {
'):',
axe.utils.performanceTimer.timeElapsed() + 'ms'
);
axe.utils.performanceTimer.mark(markStart);
axe.utils.performanceTimer.mark(markChecksStart);
}

nodes.forEach(node => {
Expand Down Expand Up @@ -212,12 +214,15 @@ Rule.prototype.run = function(context, options, resolve, reject) {
q.defer(resolve => setTimeout(resolve, 0));

if (options.performanceTimer) {
axe.utils.performanceTimer.mark(markChecksEnd);
axe.utils.performanceTimer.mark(markEnd);
axe.utils.performanceTimer.measure(
'runchecks_' + this.id,
markStart,
markEnd
markChecksStart,
markChecksEnd
);

axe.utils.performanceTimer.measure('rule_' + this.id, markStart, markEnd);
}

q.then(() => resolve(ruleResult)).catch(error => reject(error));
Expand Down