/core-rules)
    * [ Governance ](/docs/latest/contribute/governance)
    * [ Report a Security Vulnerability ](/docs/latest/contribute/report-security-vulnerability)
  * [ Maintain ESLint ](/docs/latest/maintain/)
    * [ How ESLint is Maintained ](/docs/latest/maintain/overview)
    * [ Manage Issues and Pull Requests ](/docs/latest/maintain/manage-issues)
    * [ Review Pull Requests ](/docs/latest/maintain/review-pull-requests)
    * [ Manage Releases ](/docs/latest/maintain/manage-releases)
    * [ Working Groups ](/docs/latest/maintain/working-groups)

#  Stats Data

##  Table of Contents

  1. Enable stats collection 
  2. ◆ Stats type 
    1. CLI usage 
    2. API Usage 

While an analysis of the overall rule performance for an ESLint run can be
carried out by setting the [ TIMING ](./custom-rules#profile-rule-performance)
environment variable, it can sometimes be useful to acquire more _granular_
timing data (lint time per file per rule) or collect other measures of
interest. In particular, when developing new [ custom plugins ](./plugins) and
evaluating/benchmarking new languages or rule sets. For these use cases, you
can optionally collect runtime statistics from ESLint.

##  Enable stats collection

To enable collection of statistics, you can either:

  1. Use the ` --stats ` CLI option. This will pass the stats data into the formatter used to output results from ESLint. (Note: not all formatters output stats data.) 
  2. Set ` stats: true ` as an option on the ` ESLint ` constructor. 

Enabling stats data adds a new ` stats ` key to each [ LintResult
](../integrate/nodejs-api#-lintresult-type) object containing data such as
parse times, fix times, lint times per rule.

As such, it is not available via stdout but made easily ingestible via a
formatter using the CLI or via the Node.js API to cater to your specific
needs.

##  ◆ Stats type

The ` Stats ` value is the timing information of each lint run. The ` stats `
property of the [ LintResult ](../integrate/nodejs-api#-lintresult-type) type
contains it. It has the following properties:

  * ` fixPasses ` ( ` number ` )   
The number of times ESLint has applied at least one fix after linting.

  * ` times ` ( ` { passes: TimePass[] } ` )   
The times spent on (parsing, fixing, linting) a file, where the linting refers
to the timing information for each rule.

    * ` TimePass ` ( ` { parse: ParseTime, rules?: Record<string, RuleTime>, fix: FixTime, total: number } ` )   
An object containing the times spent on (parsing, fixing, linting)

      * ` ParseTime ` ( ` { total: number } ` )   
The total time that is spent when parsing a file.

      * ` RuleTime ` ( ` { total: number } ` )  The total time that is spent on a rule. 
      * ` FixTime ` ( ` { total: number } ` )  The total time that is spent on applying fixes to the code. 

###  CLI usage

Let’s consider the following example:

    
    
    /*eslint no-regex-spaces: "error", wrap-regex: "error"*/
    
    function a() {
        return / foo/.test("bar");
    }
    
    
    1  
    2  
    3  
    4  
    5  
    

Run ESLint with ` --stats ` and output to JSON via the built-in [ ` json `
formatter ](../use/formatters/) :

    
    
    npx eslint file-to-fix.js --fix --stats -f json
    
    
    1  
    

This yields the following ` stats ` entry as part of the formatted lint
results object:

    
    
    {
        "times": {
            "passes": [
                {
                    "parse": {
                        "total": 3.975959
                    },
                    "rules": {
                        "no-regex-spaces": {
                            "total": 0.160792
                        },
                        "wrap-regex": {
                            "total": 0.422626
                        }
                    },
                    "fix": {
                        "total": 0.080208
                    },
                    "total": 12.765959
                },