代码覆盖率和性能分析之间的区别 [英] difference between code coverage and profiling

查看:69
本文介绍了代码覆盖率和性能分析之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is difference between code code coverage and profiling.

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

Which is the best open source tool for code coverage.

推荐答案

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

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.

添加:
对于覆盖率工具,我总是亲自完成。在几乎每个例程和基本块中,我都插入一个这样的调用: Utils.CovTest(文件名,例程名,说明正在执行的操作的注释)
例程记录它被调用的事实,并且在程序完成时,所有这些注释都将附加到文本文件中。
然后执行一个后处理步骤,从完整列表(由类似grep的程序获得)中减去该文件。
结果是未受测试的列表,需要其他测试用例。

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.

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

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.

这篇关于代码覆盖率和性能分析之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆