C++ 的性能测试实用程序

发布于 2024-10-10 08:13:05 字数 1539 浏览 6 评论 0原文

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

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

发布评论

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

评论(4

一页 2024-10-17 08:13:05

一些建议:

  • googletest C++ 框架能够生成与 JUnit 兼容的报告。
  • Hudson 可用于运行测试。它只要求您的 C++ 应用程序可以作为控制台应用程序运行。
  • Hudson 性能插件可以从 JUnit 报告生成图形图表。
  • 还有许多其他插件

Some suggestions:

  • The googletest C++ framework is capable of producing JUnit-compatible reports.
  • Hudson can be used to run your tests. It only requires that your C++ application can be run as a console application.
  • The Hudson Performance Plugin can generate graphical charts from JUnit reports.
  • There are many other plugins.
优雅的叶子 2024-10-17 08:13:05

有两个性能测试框架可以帮助您。

两者都受到 Google Test 框架的启发,提供了支持性能测试的接口,因此很容易传输您原来的 googletest 到 HayaiSkyPat

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.

蓝梦月影 2024-10-17 08:13:05

在 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.

手心的温暖 2024-10-17 08:13:05

一些希望来自我对此类事情的经验的相关注释此处此处

您现有的 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.

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