This is more of a note than an answer, but it doesn’t quite fit in the comment, so I hope you will not hold it against me.
The term “profiling” has several related but different meanings. In an abstract context, this means “measuring” your program, usually with respect to certain run-time data. However, this is not the same as simply “synchronizing” your program. Timing is one form of profiling, but there are many others.
For example, suppose you are not sure if any data structure should be std::set (tree) or std::unordered_set (hash table). There is no universal answer, because it depends on what you use it for and what data you process. It is possible that you cannot know the correct answer until you provide the actual data of the real world that you are going to use. In this case, “profile and solution” means that you make two versions of your program, run them against real data, and measure the execution time. Most likely, this is the one you need.
GCC, on the other hand, has a tool called a profiler that serves a completely different purpose. This is the execution path profiler, if you like, which tells you where (i.e. in which function) your program spends most of its time. If you have a complex algorithm with many routines, you may not know which ones are important, and again this may depend on your actual input. In this case, the profiler can help you determine which functions are called the most given of your input data, and you can focus on optimizing these functions. Now “profile before optimization” means that you need to prioritize before getting started.
However, for the comparison you have in mind, you should not use the GCC profiler. Rather, compile on both platforms with optimizations enabled and optimized, and then measure the execution time on the same set of input data.
source share