代码覆盖率和分析之间的区别

发布于 2024-10-26 23:07:52 字数 49 浏览 0 评论 0原文

代码代码覆盖率和分析之间有什么区别。

这是最好的代码覆盖率开源工具。

What is difference between code code coverage and profiling.

Which is the best open source tool for code coverage.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南风起 2024-11-02 23:07:52

代码覆盖率是对代码已运行量的评估。这用于查看测试对代码的执行情况。

分析用于查看代码各个部分的执行情况。

这些工具取决于您使用的语言和平台。我猜您使用的是 Java,因此推荐 CodeCover。尽管您可能会发现 NoUnit 更易于使用。

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

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

The tools depend on the language and platform you are using. I'm guessing that you are using Java, so recommend CodeCover. Though you may find NoUnit easier to use.

温柔戏命师 2024-11-02 23:07:52

覆盖率对于查看代码的哪些部分尚未运行非常重要。
根据我的经验,它必须在多个用例中积累,因为软件的任何单次运行都只会使用部分代码。

分析在不同的时间意味着不同的事情。有时这意味着衡量绩效。有时这意味着诊断内存泄漏。有时,这意味着了解多线程或其他低级活动。

当目标是通过查找所谓的“瓶颈”并修复它们来提高软件性能时,不要仅仅满足于任何分析器,甚至不一定是高度推荐或值得尊敬的分析器。
使用能够获取正确信息并以正确方式将其呈现给您的信息非常重要,因为这方面存在很多混乱。
有关该主题的更多信息.

补充:
对于覆盖工具,我一直都是自己做的。在几乎每个例程和基本块中,我都会插入这样的调用:Utils.CovTest(“文件名、例程名称、说明此处正在执行的操作的注释”)
该例程记录了它被调用的事实,当程序完成时,所有这些注释都被附加到一个文本文件中。
然后是一个后处理步骤,从完整列表(通过类似 grep 的程序获取)中“减去”该文件。
结果是尚未测试的内容的列表,需要额外的测试用例。

当不进行覆盖率测试时,Utils.CovTest 不执行任何操作。无论如何,我将它保留在最内循环之外,因此它不会对性能产生太大影响。
在 C 和 C++ 中,我使用一个宏来完成此操作,在正常使用期间,该宏不会扩展为任何内容。

Coverage is important to see which parts of the code have not been run.
In my experience it has to be accumulated over multiple use cases, because any single run of the software will only use some of the code.

Profiling means different things at different times. Sometimes it means measuring performance. Sometimes it means diagnosing memory leaks. Sometimes it means getting visibility into multi-threading or other low-level activities.

When the goal is to improve software performance, by finding so-called "bottlenecks" and fixing them, don't just settle for any profiler, not even necessarily a highly-recommended or venerable one.
It is essential to use the kind that gets the right kind of information and presents it to you the right way, because there is a lot of confusion about this.
More on that subject.

Added:
For a coverage tool, I've always done it myself. In nearly every routine and basic block, I insert a call like this: Utils.CovTest("file name, routine name, comment that tells what's being done here").
The routine records the fact that it was called, and when the program finishes, all those comments are appended to a text file.
Then there's a post-processing step where that file is "subtracted" from a complete list (gotten by a grep-like program).
The result is a list of what hasn't been tested, requiring additional test cases.

When not doing coverage testing, Utils.CovTest does nothing. I leave it out of the innermost loops anyway, so it doesn't affect performance much.
In C and C++, I do it with a macro that, during normal use, expands to nothing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文