Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
snitin315 committed Jun 15, 2022
1 parent cddad14 commit a6273b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/developer-guide/working-with-rules.md
Expand Up @@ -732,7 +732,7 @@ Performance budget ok: 1443.736547ms (limit: 3409.090909090909ms)

### Per-rule Performance

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.
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).

```bash
$ TIMING=1 eslint lib
Expand Down
2 changes: 1 addition & 1 deletion lib/linter/linter.js
Expand Up @@ -1101,7 +1101,7 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserName, languageO
)
);

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

/**
* Include `ruleId` in error logs
Expand Down
3 changes: 2 additions & 1 deletion lib/linter/timing.js
Expand Up @@ -138,10 +138,11 @@ module.exports = (function() {

return function(...args) {
let t = process.hrtime();
const result = fn(...args);

fn(...args);
t = process.hrtime(t);
data[key] += t[0] * 1e3 + t[1] / 1e6;
return result;
};
}

Expand Down

0 comments on commit a6273b8

Please sign in to comment.