We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
一些建议:
Some suggestions:
有两个性能测试框架可以帮助您。
两者都受到 Google Test 框架的启发,提供了支持性能测试的接口,因此很容易传输您原来的 googletest 到 Hayai 或 SkyPat。
SkyPat 结合了单元测试和 perf_evnet。它扩展了Google Test的概念,并提供了访问PMU的接口。 perf_event 提供 SkyPat 准确的周期计数,这对于对时序变化敏感的工具(例如编译器)非常有用。 SkyPat 还可以通过 PMU 事件(例如:周期、指令、缓存引用、缓存未命中等)分析一段代码.)。
Hayai 支持不同操作系统的多种性能测量方法(Windows:
QueryPerformanceCounter()
, Linux:gethrtime()
、Apple(OSX、iOS):mach_absolute_time()
) 进入其性能测试框架。There are two performance testing frameworks can help you.
Both of them are inspired by Google Test framework and provide interface to support performance testing, so it’s easy to transport your original googletest to Hayai or SkyPat.
SkyPat combines unit tests and perf_evnet. It extends the concept of Google Test and provides an interface to access PMU. perf_event gives SkyPat accurate cycle counts that are useful for tools that are sensitive to the variance of timing, such as compilers. SkyPat can also profile a piece of code by PMU events (eq: cycles, instructions, cache reference, cache miss, etc.).
Hayai supports several performance measuring methods of different OS (Windows:
QueryPerformanceCounter()
, Linux:gethrtime()
, Apple(OSX, iOS):mach_absolute_time()
) into its performance testing framework.在 Linux 上,您可以尝试 valgrind 工具包。 Valgrind 包含可以分析您的代码的 callgrind 工具。 KCacheGrind 很好地可视化了cachegrind 的输出。
On linux you can try the valgrind toolkit. Valgrind includes the callgrind tool that can profile your code. KCacheGrind visualizes the output of cachegrind very nicely.
一些希望来自我对此类事情的经验的相关注释此处和此处。
您现有的 CppUnit 设置与诸如
scoped_timer
之类的东西(请参阅上面的第二部分)以及对某些图表的一些后处理的结合可能不能满足您的需求。虽然我相信 CppUnit 包含一个插件(“Clocker”?),它将注销单元测试时间,但我认为它实际上对于实践中的此类性能测试没有那么有用,因为您最终总是想只对每个测试的一部分进行计时并不是所有的设置代码。Some hopefully relevant notes from my experience of this sort of thing in answers here and here.
There's no reason your existing CppUnit setup combined with something like the
scoped_timer
(see second of the above) and a bit of postprocessing to some charts maybe shouldn't satisfy your needs. While I believe CppUnit includes a plugin ("Clocker" ?) which will log out unittest times, I don't think it's actually that useful for this sort of performance testing in practice because you invariably end up wanting to time just part of each test and not all the setup code.