Evgenii Legotckoi
Evgenii LegotckoiOct. 10, 2018, 9:32 a.m.

C ++ - Does the #pragma once build speed up?

Work on a large project allows in some cases to test some theories concerning a programming language.

It was always interesting if the build is really accelerated by using the #pragma once directive instead of the classic #ifndef #define #endif .

Check this acceleration on a small project is quite problematic, because if the project is going on average for 20 seconds, then we will most likely not see a tangible acceleration, because the assembly time will always float from 17 to 23 seconds.

But I had free time and managed to test this theory on a large project.


Input data

What we have:

  • Question: Will the project build speed change if all #ifndef #define #endif changes in header files to #pragma once
  • To check this, you need to replace defaines with pragma once in 4874 header files.
  • Compiler MSVC 2017

Not to be unsubstantiated, here is a screenshot of a commit from Tortoise Git, which shows the changes in 4874 files

To save all the files, I wrote a python script, I am not the enemy myself, to fix all these files manually. Of course, not everything went smoothly and I had to fix something, but in this case it was not so much work.

Conclusion

In the end, I did not see the difference.

Before the change, the project compiled 15 minutes 52 seconds on average.

After the change, the project was compiled for 15 minutes 50 seconds on average.

If some compilers do optimizations, then this should be included with special flags. In fact, a frontal change does not give anyone an increase in assembly speed.

If you had a reverse experience, please accomplish your goal, and tell me how you achieved speeding up the assembly with #pragma once.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
ИМ
Игорь МаксимовNov. 22, 2024, 10:51 p.m.
Django - Tutorial 017. Customize the login page to Django Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
Evgenii Legotckoi
Evgenii LegotckoiNov. 1, 2024, 12:37 a.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 6:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 5:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 9:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
Now discuss on the forum
m
moogoNov. 22, 2024, 6:17 p.m.
Mosquito Spray System Effective Mosquito Systems for Backyard | Eco-Friendly Misting Control Device & Repellent Spray - Moogo ; Upgrade your backyard with our mosquito-repellent device! Our misters conce…
Evgenii Legotckoi
Evgenii LegotckoiJune 25, 2024, 1:11 a.m.
добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
t
tonypeachey1Nov. 15, 2024, 5:04 p.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
NSProject
NSProjectJune 4, 2022, 1:49 p.m.
Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…

Follow us in social networks