From 27fdc2f2ed4d4716396d9b3ff9484b617220c121 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 31 Jan 2018 01:13:41 -0800 Subject: [PATCH] perf: Add performance metrics in Rule.runChecks (#701) --- lib/core/base/rule.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/core/base/rule.js b/lib/core/base/rule.js index 44ed7e4e3c..d2c4589b5a 100644 --- a/lib/core/base/rule.js +++ b/lib/core/base/rule.js @@ -127,8 +127,11 @@ Rule.prototype.runChecks = function (type, node, options, resolve, reject) { * @param {Function} callback Function to call when evaluate is complete; receives a RuleResult instance */ Rule.prototype.run = function (context, options, resolve, reject) { + //jshint maxstatements: 17 const q = axe.utils.queue(); const ruleResult = new RuleResult(this); + const markStart = 'mark_runchecks_start_' + this.id; + const markEnd = 'mark_runchecks_end_' + this.id; let nodes; try { @@ -143,6 +146,7 @@ Rule.prototype.run = function (context, options, resolve, reject) { if (options.performanceTimer) { axe.log('gather (', nodes.length, '):', axe.utils.performanceTimer.timeElapsed()+'ms'); + axe.utils.performanceTimer.mark(markStart); } nodes.forEach(node => { @@ -180,6 +184,11 @@ Rule.prototype.run = function (context, options, resolve, reject) { }); }); + if (options.performanceTimer) { + axe.utils.performanceTimer.mark(markEnd); + axe.utils.performanceTimer.measure('runchecks_' + this.id, markStart, markEnd); + } + q.then(() => resolve(ruleResult)) .catch(error => reject(error)); };