s123
s123

Reputation: 471

How to optimize cppcheck static analysis

I want to run cppcheck with the shortest possible runtime.

Suppose I have a directory with over 3,000 .c, .cpp, and .h files. Is there a difference in performance if I run a separate cppcheck command on each file individually vs. giving cppcheck the root path to all of the files?

If there are several core files, which are included by all of the other files, will this cause a performance hit since the core file will have to be loaded and analyzed separately for each file being analyzed?

On the other hand, if the files are being analyzed individually (and not by giving cppcheck a root directory), then this means that I can analyze several files simultaneously using threads.

Upvotes: 3

Views: 2669

Answers (1)

Daniel Marjamäki
Daniel Marjamäki

Reputation: 3037

The --cppcheck-build-dir can speedup the analysis a lot. After preprocessing, Cppcheck generates a hash and compares that to the old hash. If the old and new hash are the same the old results will be reused. I believe the speedup is ~10x.

If you compile Cppcheck yourself then ensure MATCHCOMPILER is used. The speedup is ~2x.

I have the feeling that analysis in Linux is faster than in Windows.

Upvotes: 3

Related Questions