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.
Ignoring files
Section titled “Ignoring files”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.
Metrics
Section titled “Metrics”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:
knip --performanceignoreExportsUsedInFile
Section titled “ignoreExportsUsedInFile”The ignoreExportsUsedInFile option slows down the process slightly. Typically, anywhere between 0.25% and 10% of total running time. To find out:
knip --performance-fn hasRefsInFileA last resort
Section titled “A last resort”In case Knip is unbearably slow (or even crashes), you could resort to lint individual workspaces.
ISC License © 2024 Lars Kappert