Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6273b8

Browse files
authored
feat: account for rule creation time in performance reports (#15982)
* feat: account for rule creation time in performance reports * docs: update info about per-rule performance * Revert "docs: update info about per-rule performance" This reverts commit 560b280. * docs: update info about per-rule performance
1 parent cddad14 commit a6273b8

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

docs/src/developer-guide/working-with-rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ Performance budget ok: 1443.736547ms (limit: 3409.090909090909ms)
732732

733733
### Per-rule Performance
734734

735-
ESLint has a built-in method to track performance of individual rules. Setting the `TIMING` environment variable will trigger the display, upon linting completion, of the ten longest-running rules, along with their individual running time and relative performance impact as a percentage of total rule processing time.
735+
ESLint has a built-in method to track performance of individual rules. Setting the `TIMING` environment variable will trigger the display, upon linting completion, of the ten longest-running rules, along with their individual running time (rule creation + rule execution) and relative performance impact as a percentage of total rule processing time (rule creation + rule execution).
736736

737737
```bash
738738
$ TIMING=1 eslint lib

lib/linter/linter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserName, languageO
11011101
)
11021102
);
11031103

1104-
const ruleListeners = createRuleListeners(rule, ruleContext);
1104+
const ruleListeners = timing.enabled ? timing.time(ruleId, createRuleListeners)(rule, ruleContext) : createRuleListeners(rule, ruleContext);
11051105

11061106
/**
11071107
* Include `ruleId` in error logs

lib/linter/timing.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ module.exports = (function() {
138138

139139
return function(...args) {
140140
let t = process.hrtime();
141+
const result = fn(...args);
141142

142-
fn(...args);
143143
t = process.hrtime(t);
144144
data[key] += t[0] * 1e3 + t[1] / 1e6;
145+
return result;
145146
};
146147
}
147148

0 commit comments

Comments
 (0)