Uppsats
Analyzing and Reducing Compilation Times for C++ Programs
Master-uppsats
Linköpings universitet/Programvara och system
Publicerad: 2022
Språk: Engelska
Nyckelord
klicka för att sökaSammanfattning
Software companies often choose to develop in C++ because of the high performance that the language offers. Facilitated by static compilation and powerful optimization options, runtime performance is paid for with compilation time. Although the trade-off is inevitable to some extent, building very large C++ programs from scratch can take up to several hours if extra care is not taken during development. This thesis analyzes compilation times for C++ programs and shows how they can be reduced with the help of design patterns, implementation hiding, and framework related fixes. The results presented prove that compilation times can be decreased significantly with no drawbacks to the maintainability of a program. An in-depth analysis of compilation times and dependencies has been conducted for two large software modules from a representative company. Both modules take over an hour of CPU time each to compile. The time consumption for different compiler activities, such as parsing, preprocessing, and runtime optimization tasks have been measured for the modules. The compilation times for unit tests and mocks which use the GoogleTest framework have been analyzed. A simple method that may reduce compilation times by up to 50% for programs that use GoogleTest is presented. A dependency metric has been created, based on the number of include statements found recursively throughout a program. The dependency metric was found to be connected to compilation time for the two analyzed modules. Other factors that can influence compilation times are also shown, such as runtime optimization options, and the use of templates. Experiments which show how a typical usage of templates can drastically increase compilation times are presented. In addition, a solution which allows templates to be used while avoiding code bloat across translation units is reviewed. The solution effectively rivals non-template code in terms of compilation time. The Pointer to Implementation (PImpl) and Dependency Injection design patterns have been used to refactor a small program. Both design patterns performed well, reducing the total compilation time and total compiler memory usage by 70%. A program that detects dependency cycles has been created, but no cycles were found in any of two modules from the representative company.
Information
- Författare
- Mivelli, Dennis
- Lärosäte / institution
- Linköpings universitet/Programvara och system
- Publiceringsdatum
- 2022
- Uppsatstyp
- Master-uppsats
- Språk
- Engelska
- Nyckelord
- ⌕Design patterns⌕C#⌕speed⌕Tid⌕time⌕large⌕Byggtid⌕Bridge⌕reduce⌕Designmönster⌕Hastighet⌕Dependencies⌕large-scale⌕Beroenden⌕Storskalig⌕Compilation⌕Kompilering⌕Minska⌕Build⌕File Dependencies⌕File inclusions⌕Compilation time⌕Build time⌕PImpl⌕Dependency injection⌕Pointer to implementation⌕Mocking⌕GoogleTest⌕gMock⌕Reduce compilation times⌕Reduce build times⌕Filberoenden⌕Filinkluderingar⌕Kompileringstid⌕Mockning⌕Minska kompileringstid
Utforska vidare
Liknande uppsatser
Uppsatser med liknande ämnen och nyckelord.
Yrkesexamen på avancerad nivå, Högskolan i Halmstad/Akademin för lärande, humaniora och samhälle
Göransson, Julia, Jakobsson, Daniella, Johansson, Carina
Publicerad: 2025
Master-uppsats, Göteborgs universitet/Institutionen för data- och informationsteknik
Ganesh, Sundarakrishnan, Sahlqvist, Robert
Publicerad: 2024-10-16
Master-uppsats, Göteborgs universitet/Förvaltningshögskolan
Lundgren, Klara, Nilsson, Alexandra
Publicerad: 2025-06-17
Master-uppsats, Uppsala universitet/Filosofiska institutionen
Silva, Lucas
Publicerad: 2026
Master-uppsats, Uppsala universitet/Institutionen för informatik och media
Strömberg, Viggo
Publicerad: 2026
Master-uppsats, KTH/Bro- och stålbyggnad
Kayhan, Özge
Publicerad: 2026