The difference between code coverage and profiling

What is the difference between code coverage and profiling?

What is the best open source tool for code coverage.

+2
profiling code-coverage
source share
2 answers

Coverage is important to see which parts of the code have not been executed. In my experience, it should accumulate in several use cases, because any single launch of the software will use only some code.

Profiling means different things at different times. Sometimes this means measuring performance. Sometimes this means diagnosing memory leaks. Sometimes this means gaining visibility in multi-threaded or other low-level activities.

When the goal is to improve software performance by looking for so-called bottlenecks and fixing them, don't just settle for a profiler, not even a highly recommended or respectable one. It is imperative to use the view that receives the right information and presents it to you in the right direction, because there is a lot of confusion about this. More on this.

Added: For the coverage tool, I always did it myself. In almost every regular and basic block, I insert this call: Utils.CovTest("file name, routine name, comment that tells what being done here") . The subroutine records the fact that it was called, and when the program ends, all these comments are added to the text file. Then there is a post-processing step in which this file is "subtracted" from the full list (obtained by grep-like). The result is a list of what has not been tested, requiring additional test cases.

When you do not test coverage, Utils.CovTest does nothing. I leave it out of the innermost loops anyway, so this doesn't greatly affect performance. In C and C ++, I do this with a macro, which, under normal use, expands to zero.

+1
source share

Code coverage is an assessment of how much of your code has been run. This is used to see how well your tests used your code.

Profiling is used to see how the various parts of your code work.

Tools depend on the language and platform you are using. I assume you are using Java, so I recommend CodeCover . Although you can easily find NoUnit .

+1
source share

All Articles