如何在 g++ 中使用配置文件引导的优化?

2023-05-09C/C++开发问题
1

本文介绍了如何在 g++ 中使用配置文件引导的优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

另外,谁能给我指点关于这个主题的好教程?我找不到.

Also, can anyone point me to a good tutorial on the subject? I can't find any.

推荐答案

-fprofile-generate 将使用分析代码检测应用程序.如果在编译时已知此使用模式,应用程序将在实际运行时记录某些可以提高性能的事件.分支、内联的可能性等都可以记录,但我不确定 GCC 是如何实现这一点的.

-fprofile-generate will instrument the application with profiling code. The application will, while actually running, log certain events that could improve performance if this usage pattern was known at compile time. Branches, possibility for inlining, etc, can all be logged, but I'm not sure in detail how GCC implements this.

程序退出后,它会将所有这些数据转储到 *.gcda 文件中,这些文件本质上是测试运行的日志数据.使用 -fprofile-use 标志重建应用程序后,GCC 在进行优化时会考虑 *.gcda 日志数据,通常会显着提高性能.当然,这取决于很多因素.

After the program exits, it will dump all this data into *.gcda files, which are essentially log data for a test run. After rebuilding the application with -fprofile-use flag, GCC will take the *.gcda log data into account when doing its optimizations, usually increasing the performance significantly. Of course, this depends on many factors.

这篇关于如何在 g++ 中使用配置文件引导的优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6