Skip to content

Performance

This page describes a few topics around Knip’s performance, and how you might improve it.

Knip does not want to tell you how to structure files or how to write your code, but it might still be good to understand inefficient patterns for Knip.

Use the --debug and --performance flags to find potential bottlenecks.

Use --cache to speed up consecutive runs.

Files matching the ignore patterns are not excluded from the analysis. They’re just not printed in the report. Use negated entry and project patterns to exclude files from the analysis.

Read configuring project files for details and examples. Improving configuration may have a significant impact on performance.

Use the --performance flag to see how many times potentially expensive functions (e.g. findReferences) are invoked and how much time is spent in those functions. Example usage:

Terminal window
knip --performance

The ignoreExportsUsedInFile option slows down the process slightly. Typically, anywhere between 0.25% and 10% of total running time. To find out:

Terminal window
knip --performance-fn hasRefsInFile

In case Knip is unbearably slow (or even crashes), you could resort to lint individual workspaces.

ISC License © 2024 Lars Kappert