Comparison of Qt's foreach and range-based for in C++11
-
Hi,
I have made some benchmarking to compare foreach and range-for performance on QVector and QHash. I think some of you may find the results interesting.
The benchmark code and the results are "here":https://bugreports.qt-project.org/browse/QTBUG-41636
Edit: I have fixed the benchmark so that copying the container takes place inside the benchmark loop. Benchmark code and results are updated in the report.
-
[quote author="Ildar" date="1411887195"]Thank you for this test!
I have some questions:- Are you compiling in release mode?
- What level of optimization - O1, O2, O3?[/quote]
Yes, I've run the tests in release mode. Optimization level is -O2 for both cland and gcc. I am using qmake to build the projects, so these are the defaults.
-
This looks like good content for the wiki, at least in the short term.
http://qt-project.org/wiki/Category:Developing_with_Qt::Performance_Tips