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

feat: account for rule creation time in performance reports #15982

Merged
merged 4 commits into from Jun 15, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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).

snitin315 marked this conversation as resolved.
Show resolved Hide resolved
```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