Skip to content

Commit b69daf4

Browse files
committed
Added performance metrics
1 parent af7c35d commit b69daf4

File tree

4 files changed

+391
-85
lines changed

4 files changed

+391
-85
lines changed

lib/core/base/rule.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,21 @@ Rule.prototype.gather = function gather(context, options = {}) {
146146
performanceTimer.measure(
147147
'rule_' + this.id + '#gather_axe.utils.isHidden',
148148
markHiddenStart,
149-
markHiddenEnd
149+
markHiddenEnd,
150+
{
151+
rule: this.id,
152+
type: "rule"
153+
}
150154
);
151155
}
152156
}
153157

154158
if (options.performanceTimer) {
155159
performanceTimer.mark(markEnd);
156-
performanceTimer.measure('rule_' + this.id + '#gather', markStart, markEnd);
160+
performanceTimer.measure('rule_' + this.id + '#gather', markStart, markEnd, {
161+
rule: this.id,
162+
type: "rule"
163+
});
157164
}
158165

159166
return elements;
@@ -368,7 +375,7 @@ Rule.prototype._trackPerformance = function _trackPerformance() {
368375
* @param {Array} nodes Result of rule.gather
369376
*/
370377
Rule.prototype._logGatherPerformance = function _logGatherPerformance(nodes) {
371-
log('gather (', nodes.length, '):', performanceTimer.timeElapsed() + 'ms');
378+
// log('gather (', nodes.length, '):', performanceTimer.timeElapsed() + 'ms');
372379
performanceTimer.mark(this._markChecksStart);
373380
};
374381

@@ -383,10 +390,17 @@ Rule.prototype._logRulePerformance = function _logRulePerformance() {
383390
performanceTimer.measure(
384391
'runchecks_' + this.id,
385392
this._markChecksStart,
386-
this._markChecksEnd
393+
this._markChecksEnd,
394+
{
395+
rule: this.id,
396+
type: "rule"
397+
}
387398
);
388399

389-
performanceTimer.measure('rule_' + this.id, this._markStart, this._markEnd);
400+
performanceTimer.measure('rule_' + this.id, this._markStart, this._markEnd, {
401+
rule: this.id,
402+
type: "rule"
403+
});
390404
};
391405

392406
/**
@@ -444,7 +458,11 @@ Rule.prototype.gatherAndMatchNodes = function gatherAndMatchNodes(
444458
performanceTimer.measure(
445459
'rule_' + this.id + '#matches',
446460
markMatchesStart,
447-
markMatchesEnd
461+
markMatchesEnd,
462+
{
463+
rule: this.id,
464+
type: "rule"
465+
}
448466
);
449467
}
450468

lib/core/utils/performance-timer.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const performanceTimer = (() => {
3737
this.mark('mark_axe_end');
3838
this.measure('axe', 'mark_axe_start', 'mark_axe_end');
3939

40-
this.logMeasures('axe');
40+
// this.logMeasures('axe');
4141
},
4242
/**
4343
* @member {Function} auditStart Starts an audit for a page or frame
@@ -52,7 +52,7 @@ const performanceTimer = (() => {
5252
this.mark('mark_audit_end');
5353
this.measure('audit_start_to_end', 'mark_audit_start', 'mark_audit_end');
5454
// log audit/rule measures
55-
this.logMeasures();
55+
// this.logMeasures();
5656
},
5757
/**
5858
* @member {Function} mark Shims creating a new named time stamp, called a mark
@@ -72,9 +72,19 @@ const performanceTimer = (() => {
7272
* @param {String} startMark String name of mark to start measuring
7373
* @param {String} endMark String name of mark to end measuring
7474
*/
75-
measure(measureName, startMark, endMark) {
75+
measure(measureName, startMark, endMark, details = {}) {
7676
if (window.performance && window.performance.measure !== undefined) {
77-
window.performance.measure(measureName, startMark, endMark);
77+
if(Object.keys(details).length > 0) {
78+
const measureOpts = {
79+
detail: details,
80+
start: startMark,
81+
end: endMark
82+
};
83+
window.performance.measure(measureName, measureOpts);
84+
}
85+
else {
86+
window.performance.measure(measureName, startMark, endMark);
87+
}
7888
}
7989
},
8090
/**

0 commit comments

Comments
 (0)