Click here to Skip to main content
Full site     10M members (39.3K online)    

C++ Include test: full matrix

Finally I am able to present some include experiment results! Previously I wrote about Code Generator and now I can actually run this tool and get some numbers out of it. I compared VC11.0 (Visual Studio 2012 For Desktop) and GCC 4.7.2 (using MinGW32 4.7.2 and DevCpp).

Basics of experiment

I run each test 3 times and then compute the average. At the end of post there is a link to detailed spreadsheet.

Code structure

The overall code structure is not a real case scenario. It was my first attempt to do such experiment and it was actually easy to create such hierarchy.

Note: For 199 GCC will return an error "#include nested too deeply". You can read more about it in gamesfromwithin.com. In general GCC thinks that 199 include level is unreal and will block it.

Test N headers

A header can look like this in this tests: 

#ifndef _INCLUDED_HEADER_HEADER_5_H
    #define _INCLUDED_HEADER_HEADER_5_H 
    #include "header_0.h"
    #include "header_1.h"
    #include "header_2.h"
    #include "..."  
generator.exe N 100 includeTestOutput/
N = 100
GCC3,95s
GCC Compilation2,99s
VC11.02,90s
VC11.0 Compilation2,68s
N = 132
GCC5,37s
GCC Compilation3,98s
VC11.04,31s
VC11.0 Compilation4,11s
N = 164
GCC6,49s
GCC Compilation4,92s
VC11.06,10s
VC11.0 Compilation5,91s
N = 192
GCC7,40s
GCC Compilation5,77s
VC11.07,98s
VC11.0 Compilation7,77s

Test N headers - additional ifDef

A header can look like this in this tests:

#ifndef _INCLUDED_HEADER_HEADER_5_H
    #define _INCLUDED_HEADER_HEADER_5_H
    #ifndef _INCLUDED_HEADER_HEADER_0_H
        #include "header_0.h"
    #endif
    #ifndef _INCLUDED_HEADER_HEADER_1_H
        #include "header_1.h"
    #endif
    #ifndef _INCLUDED_HEADER_HEADER_2_H
        #include "header_2.h"
    #endif
    #include "..." 
generator.exe N 100 includeTestOutput/ ifDef
N = 100
GCC3,91s
GCC Compilation2,96s
VC11.01,44s
VC11.0 Compilation1,22s
N = 132
GCC5,35s
GCC Compilation3,91s
VC11.01,71s
VC11.0 Compilation1,51s
N = 164
GCC6,41s
GCC Compilation4,86s
VC11.01,98s
VC11.0 Compilation1,77s
N = 192
GCC7,31s
GCC Compilation5,69s
VC11.02,16s
VC11.0 Compilation1,96s

Test N headers - #pragma once

A header can look like this in this tests:

#pragma once
    #ifndef _INCLUDED_HEADER_HEADER_5_H
    #define _INCLUDED_HEADER_HEADER_5_H
    #include "header_0.h"
    #include "header_1.h"
    #include "header_2.h"
    #include "..." 
generator.exe N 100 includeTestOutput/ pragmaOnce
N = 100
GCC4,02s
GCC Compilation3,08s
VC11.01,48s
VC11.0 Compilation1,28s
N = 132
GCC5,42s
GCC Compilation4,06s
VC11.01,84s
VC11.0 Compilation1,65s
N = 164
GCC6,64s
GCC Compilation5,08s
VC11.02,06s
VC11.0 Compilation1,86s
N = 192
GCC7,60s
GCC Compilation5,98s
VC11.02,39s
VC11.0 Compilation2,20s

Conclusion

What I have learnt

Links

Link to repo
Link to spreadsheet 
Article is posted also on the CodeProject
 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search 
Per page   
GeneralMy vote of 4
Jayanta Chatterjee
13 Apr '13 - 2:25 
GeneralRe: My vote of 4
Bartlomiej Filipek
15 Apr '13 - 8:46 
GeneralRe: My vote of 4
Jayanta Chatterjee
16 Apr '13 - 4:17 

Last Updated 17 Apr 2013 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2013