no, seriously, tl;dr

How the Test Works
Optimizing the Test
Reasonable Confidence
Bias
TL;DR
Results by Compiler
Results by C++ Standard

Heuristics

In the first post, C++ Headers Are Expensive!, I posted a bunch of compilation times for includes, gave some vague hand wavy explanation of how I captured the data and pretty much left it at that. In the second post, C++ Compliation: What’s Slowing Us Down? I examined some things interfering with the compilation speed which were outside of the test. In this post I’m updating the compilation numbers, adding some more details on how the testing works, and most importantly, I’m going to show reasonable confidence in the numbers and what this does for future posts.

How the Test Works

The test iterates over a list of compilers, C++ standard versions, and headers. For each, it invokes the compiler on a source file that includes the relevant header and times how long it takes. The source code for each test is a simple function which returns an integer and takes no parameters; it only requires core logic of the language and is intentionally neither special nor complicated. When running the tests, if the header requires a higher C++ standard than is being currently tested, it is marked as “unsupported” and skipped, otherwise the test is run some number of times, storing the elapsed time for each iteration for later processing.

I exclude the time it takes to start the compiler and parse a constant block of code by compiling the unmodified code and calculate how long it takes. This is done hundreds of times and averaged together. The higher the iteration count of the baseline test, the higher accuracy the baseline time is, assuming the compilation ends up taking generally the same amount of time. The baseline is then subtracted from test times, giving us the true cost of the change.

The baseline code looks like this:

int testFunction() { return 0; }

The test code adds the code we’re going to test. In this case, we’re adding an include so we can see how much time this costs:

#include <assert.h>
int testFunction() { return 0; }

Optimizing the Test

The full test takes 10 to 24 hours to run, so any speed gains allow me to running more iterations, or a have a higher frequency of tests.

In the second post, I fixed some of the “easy” stuff which was causing variability in testing. I wanted to avoid making changes that affect the compilation itself, instead only reducing outside interference, reducing the amount of time the tests take as well as increase their repeatability.

I tried running one compilation per core but that made the results unreliable due to the compilers stomping each other in various ways.

Outside of that, I haven’t done anything, even the oft suggested “dude, ssd!”

Reasonable Confidence

There can be no meaningful change without meaningful measurement. In order to present the results, I need to have some reasonable confidence that the numbers are correct.

For my purposes, “reasonable confidence” is saying “Header soandso took N seconds” and have a way to prove that the result is statistically likely. To do this, I run the test a large number of times. The time of each iteration is plotted to a graph and then a sliding window of time is adjusted until we cover a high percentage of results.

An important note here is that heuristics like this cannot actually predict future results, instead, it can only say “of the data given, X percentage of them occurred within Y range.” Given that the test is done the same way every time on the same machine under the same conditions, we would expect that the results will be similar. So, if you’re keeping score, yes, we expect it’ll be the same, but no we can’t actually predict it… it’s all just so confusing!

Once we’ve got some data, there are three things we can do to get try to make some meaningful sense out of them:

  1. Grow the window (fits a higher percentage of tests within the window, but also a widens the range of result times)
  2. Shrink the window (defines a narrower range of result times, but that lowers the percent of tests within the window)
  3. Gather More Data! Assuming repeatability, this should allow us to shrink the window and still have a narrow range of result times.

So the goal is to figure out how many iterations need to be run in order to achieve a desired percentage of tests falling within a certain range of time.

That number is currently between 128 and 256 iterations, but I use 128 as the test runs in “only” 10 hours. Surprisingly, warmup tests (running the test to preload hard drive/memory caches) actually has negligible influence on this. Previously, I was running the number of test iterations twice and skipping the results of the first test, but it turns out, this was a huge waste of time. Oh well!

Bias

I try to avoid injecting my opinion, desires, or hopeful results into the tests. It’s easy to tweak statistics to give desired results versus reality.

None of that is good, so to avoid it, I am providing as much information as I have that a) is required to have reasonable confidence in my results, and b) I think people will reasonably care about. I’ll provide high level results and confidence(s) I have in that range of data, and I’ll sometimes (but not all of the time) provide raw results. To be honest, though, maybe 1% of the folks that’ll ever read this will want or actually do anything with that data. If I don’t provide it (or at least proof that it’s accurate) I may as well just type in my own numbers into the table.

That being said, if you _do_ want that full data for future posts, let me know (twitter: @virtuallyrandom) and I’ll make a reasonable attempt to get it to you.

TL;DR

These tests covered Microsoft Visual Studio 2015, Microsoft Visual Studio 2017, and clang 7.0.1 for C++ standards C++20, C++17, C++14, C++11, C++03, and C++98. Baseline time was calculated by compiling basic source code 128 times. Result time was calculated by compiling adjusted source code (include + basic source code) 128 times.

For the sake of brevity, compilers are annoted as VS15 for Visual Studio 2015’s cl.exe, VS17 for Visual Studio 2017’s cl.exe, or clang for, well, clang.

Due to the amount of content, I’m posting several batches of data. The first batch is a table which contains the results for each header in each compiler under only the C++14 standard. The second batch is a table for each compiler for each header under each C++ standard. The third batch is hueristic data that gives the confidence time range and occupancy for each compiler, each header, and each standard. Finally, there are zips of all of this data (in tabe delimited text files) so folks can peruse and validate the data themselves.

Results by Compiler

This is a table of compilation times, in seconds, for each compiler using the C++14 standard. That standard was chosen as it supported by all three compilers tested.

HeaderVS15VS17clang
algorithm0.1690.1910.316
anyunsupportedunsupportedunsupported
array0.2840.3530.506
assert.h0.0090.0080.014
atomic0.3260.4050.659
bitunsupportedunsupportedunsupported
bitset0.3290.4150.527
cassert0.010.0090.017
cctype0.0120.0110.023
cerrno0.0110.0090.018
cfenv0.0120.0110.022
cfloat0.0110.0090.019
charconv 0.341 0.432 0.542
chrono0.1440.1950.306
cinttypes0.0140.0110.021
climits0.010.0090.018
clocale0.0110.0090.019
cmath0.0360.0450.084
codecvtunsupportedunsupportedunsupported
compareunsupportedunsupportedunsupported
complex0.3440.440.558
conceptsunsupportedunsupportedunsupported
condition_variable0.2860.3720.51
contractunsupportedunsupportedunsupported
csetjmp0.0110.010.018
csignal0.010.0090.017
cstdarg0.010.010.018
cstddef0.010.0130.021
cstdint0.0110.0090.018
cstdio0.0430.0430.073
cstdlib0.010.0270.058
cstring0.0180.0190.038
ctime0.0130.0130.025
ctype.h0.0130.010.02
cuchar0.0110.010.018
cwchar0.040.0450.082
cwctype0.0140.010.02
deque0.1830.2160.339
errno.h0.0090.0080.015
exception0.0480.0680.103
executionunsupportedunsupportedunsupported
fenv.h0.010.0090.018
filesystemunsupportedunsupportedunsupported
float.h0.0090.0080.016
forward_list0.1830.2140.338
fstream0.2710.3310.476
functional0.1870.2220.361
future1.0591.3171.474
initializer_list0.0110.0130.022
inttypes.h0.010.0090.016
iomanip0.2720.3350.482
ios0.2590.3180.456
iosfwd0.080.0940.172
iostream0.2640.3250.464
istream0.2640.3240.463
iterator0.2650.3270.468
limits0.0790.0890.163
limits.h0.0040.0060.012
list0.1830.2140.338
locale0.3370.4270.545
locale.h0.010.010.016
map0.1940.2310.363
math.h0.0150.0160.03
memory0.1730.20.324
memory_resourceunsupportedunsupportedunsupported
mutex0.280.3640.498
new0.0520.0670.106
numeric0.1090.1440.236
optionalunsupportedunsupportedunsupported
ostream0.2610.3210.459
queue0.1980.2350.374
random0.3050.3940.553
rangesunsupportedunsupportedunsupported
ratio0.0460.0620.103
regex0.3920.5050.634
scoped_allocator0.1710.1980.323
set0.1850.2170.341
setjmp.h0.0040.0060.013
shared_mutex0.2890.3790.508
signal.h0.0120.0080.015
spanunsupportedunsupportedunsupported
sstream0.3290.4160.528
stack0.1860.2160.341
stdarg.h0.0040.0070.006
stddef.h0.0090.0080.007
stdexcept0.1770.2080.33
stdint.h0.0050.0060.013
stdio.h0.0370.0420.069
stdlib.h0.0170.0180.039
streambuf0.2540.3110.444
string0.3270.4130.523
string_viewunsupportedunsupportedunsupported
string.h0.0160.0170.034
strstream0.2850.3580.492
syncstreamunsupportedunsupportedunsupported
system_error0.2080.2460.365
thread0.2270.2890.448
time.h0.0110.0120.022
tuple0.1230.1630.263
type_traits0.0430.060.096
typeindex0.0520.0690.109
typeinfo0.0510.0680.107
uchar.h0.0090.0090.015
unordered_map0.2040.2450.384
unordered_set0.1940.2310.365
utility0.0980.1270.212
valarray0.1740.1980.319
variantunsupportedunsupportedunsupported
vector0.1850.2170.344
versionunsupportedunsupportedunsupported
wchar.h0.0380.0430.078
wctype.h0.010.0080.017
windows.h0.4230.5171.038

Results by C++ Standard

Microsoft Visual Studio 2015

Headerc++14c++11c++03c++98
algorithm0.1690.170.17unsupported
anyunsupportedunsupportedunsupportedunsupported
array0.2840.284unsupportedunsupported
assert.h0.0090.010.010.01
atomic0.3260.327unsupportedunsupported
bitunsupportedunsupportedunsupportedunsupported
bitset0.3290.3290.329unsupported
cassert0.010.0110.011unsupported
cctype0.0120.0130.013unsupported
cerrno0.0110.0110.011unsupported
cfenv0.0120.012unsupportedunsupported
cfloat0.0110.0160.012unsupported
charconvunsupportedunsupportedunsupportedunsupported
chrono0.1440.145unsupportedunsupported
cinttypes0.0140.012unsupportedunsupported
climits0.010.0110.011unsupported
clocale0.0110.0110.011unsupported
cmath0.0360.0370.037unsupported
codecvt0.341 0.342unsupportedunsupported
compareunsupportedunsupportedunsupportedunsupported
complex0.3440.3460.345unsupported
conceptsunsupportedunsupportedunsupportedunsupported
condition_variable0.2860.285unsupportedunsupported
contractunsupportedunsupportedunsupportedunsupported
csetjmp0.0110.0110.011unsupported
csignal0.010.0110.011unsupported
cstdarg0.010.0120.011unsupported
cstddef0.010.0110.011unsupported
cstdint0.0110.011unsupportedunsupported
cstdio0.0430.040.039unsupported
cstdlib0.010.020.02unsupported
cstring0.0180.0180.019unsupported
ctime0.0130.0140.014unsupported
ctype.h0.0130.0110.0110.011
cuchar0.0110.011unsupportedunsupported
cwchar0.040.0410.041unsupported
cwctype0.0140.0120.014unsupported
deque0.1830.1840.184unsupported
errno.h0.0090.0120.010.01
exception0.0480.0490.049unsupported
executionunsupportedunsupportedunsupportedunsupported
fenv.h0.010.0120.0110.011
filesystemunsupportedunsupportedunsupportedunsupported
float.h0.0090.010.010.01
forward_list0.1830.184unsupportedunsupported
fstream0.2710.2680.269unsupported
functional0.1870.1870.188unsupported
future1.0591.058unsupportedunsupported
initializer_list0.0110.014unsupportedunsupported
inttypes.h0.010.010.0110.011
iomanip0.2720.2730.272unsupported
ios0.2590.260.259unsupported
iosfwd0.080.080.08unsupported
iostream0.2640.2640.265unsupported
istream0.2640.2640.264unsupported
iterator0.2650.2660.266unsupported
limits0.0790.080.08unsupported
limits.h0.0040.0050.0050.005
list0.1830.1840.184unsupported
locale0.3370.3380.339unsupported
locale.h0.010.010.010.013
map0.1940.1940.195unsupported
math.h0.0150.0150.0170.016
memory0.1730.1730.173unsupported
memory_resourceunsupportedunsupportedunsupportedunsupported
mutex0.280.28unsupportedunsupported
new0.0520.050.051unsupported
numeric0.1090.1090.11unsupported
optionalunsupportedunsupportedunsupportedunsupported
ostream0.2610.2610.264unsupported
queue0.1980.1980.2unsupported
random0.3050.306unsupportedunsupported
rangesunsupportedunsupportedunsupportedunsupported
ratio0.0460.046unsupportedunsupported
regex0.3920.392unsupportedunsupported
scoped_allocator0.1710.172unsupportedunsupported
set0.1850.1860.186unsupported
setjmp.h0.0040.0050.0060.005
shared_mutex0.2890.2910.2890.29
signal.h0.0120.010.010.01
spanunsupportedunsupportedunsupportedunsupported
sstream0.3290.330.329unsupported
stack0.1860.1850.185unsupported
stdarg.h0.0040.0050.0050.006
stddef.h0.0090.010.010.01
stdexcept0.1770.1780.178unsupported
stdint.h0.0050.0050.0050.006
stdio.h0.0370.0390.0380.038
stdlib.h0.0170.0180.0180.018
streambuf0.2540.2560.255unsupported
string0.3270.3280.328unsupported
string_viewunsupportedunsupportedunsupportedunsupported
string.h0.0160.0170.0180.018
strstream0.2850.2860.285unsupported
syncstreamunsupportedunsupportedunsupportedunsupported
system_error0.2080.208unsupportedunsupported
thread0.2270.228unsupportedunsupported
time.h0.0110.0120.0130.013
tuple0.1230.123unsupportedunsupported
type_traits0.0430.044unsupportedunsupported
typeindex0.0520.053unsupportedunsupported
typeinfo0.0510.0530.052unsupported
uchar.h0.0090.010.010.013
unordered_map0.2040.205unsupportedunsupported
unordered_set0.1940.194unsupportedunsupported
utility0.0980.0980.098unsupported
valarray0.1740.1730.173unsupported
variantunsupportedunsupportedunsupportedunsupported
vector0.1850.1870.186unsupported
versionunsupportedunsupportedunsupportedunsupported
wchar.h0.0380.0390.040.04
wctype.h0.010.010.0110.011
windows.h0.4230.420.4210.421

Microsoft Visual Studio 2017

Headerc++20c++17c++14c++11c++03c++98
algorithm0.1910.1950.1910.1910.189unsupported
anyerror0.196unsupportedunsupportedunsupportedunsupported
array0.3530.3660.3530.354unsupportedunsupported
assert.h0.0070.0070.0080.0080.0060.007
atomic0.4070.4090.4050.406unsupportedunsupported
biterrorunsupportedunsupportedunsupportedunsupportedunsupported
bitset0.4150.4420.4150.4150.414unsupported
cassert0.0090.0080.0090.0090.007unsupported
cctype0.0110.0130.0110.0120.01unsupported
cerrno0.010.0080.0090.010.008unsupported
cfenv0.0110.010.0110.011unsupportedunsupported
cfloat0.010.010.0090.010.009unsupported
charconverrorerrorunsupportedunsupportedunsupportedunsupported
chrono0.1940.1960.1950.195unsupportedunsupported
cinttypes0.0180.010.0110.011unsupportedunsupported
climits0.0090.0080.0090.0090.009unsupported
clocale0.0090.0110.0090.0120.008unsupported
cmath0.0420.0410.0450.0420.041unsupported
codecvtunsupported0.4570.4320.431unsupportedunsupported
compareerrorunsupportedunsupportedunsupportedunsupportedunsupported
complex0.440.4660.440.440.439unsupported
conceptserrorunsupportedunsupportedunsupportedunsupportedunsupported
condition_variable0.3720.4110.3720.372unsupportedunsupported
contracterrorunsupportedunsupportedunsupportedunsupportedunsupported
csetjmp0.010.0110.010.010.009unsupported
csignal0.0090.0090.0090.0090.008unsupported
cstdarg0.0090.0090.010.0090.008unsupported
cstddef0.0120.0130.0130.0130.011unsupported
cstdint0.0130.0080.0090.009unsupportedunsupported
cstdio0.0450.0430.0430.0440.042unsupported
cstdlib0.0260.0260.0270.0270.025unsupported
cstring0.0180.0180.0190.0180.017unsupported
ctime0.0140.0120.0130.0130.011unsupported
ctype.h0.0090.0090.010.010.0080.012
cuchar0.0090.010.010.011unsupportedunsupported
cwchar0.0450.0440.0450.0450.044unsupported
cwctype0.010.010.010.0110.009unsupported
deque0.2140.2220.2160.2150.213unsupported
errno.h0.0080.0090.0080.0080.0060.008
exception0.0650.0670.0680.0660.064unsupported
executionerrorerrorunsupportedunsupportedunsupportedunsupported
fenv.h0.0090.0090.0090.010.0090.009
filesystem0.7730.772unsupportedunsupportedunsupportedunsupported
float.h0.0080.0080.0080.0080.0070.008
forward_list0.2140.2210.2140.214unsupportedunsupported
fstream0.3310.3440.3310.3390.329unsupported
functional0.2220.2850.2220.2220.22unsupported
future1.3171.3531.3171.319unsupportedunsupported
initializer_list0.0130.0130.0130.013unsupportedunsupported
inttypes.h0.0080.0080.0090.0120.0070.008
iomanip0.3360.350.3350.3360.334unsupported
ios0.3190.3320.3180.3190.317unsupported
iosfwd0.0940.0940.0940.0940.092unsupported
iostream0.3250.3380.3250.3240.324unsupported
istream0.3240.3380.3240.3240.322unsupported
iterator0.3280.3430.3270.3290.328unsupported
limits0.0890.090.0890.090.087unsupported
limits.h0.0080.0050.0060.0070.0040.006
list0.2140.2220.2140.2150.212unsupported
locale0.4270.4520.4270.4270.425unsupported
locale.h0.0080.0070.010.0080.0060.008
map0.2320.2390.2310.2310.23unsupported
math.h0.0150.0140.0160.0150.0130.015
memory0.20.2020.20.20.198unsupported
memory_resourceerrorerrorunsupportedunsupportedunsupportedunsupported
mutex0.3650.4040.3640.365unsupportedunsupported
new0.0660.0680.0670.0670.065unsupported
numeric0.1430.1450.1440.1430.141unsupported
optionalerror0.196unsupportedunsupportedunsupportedunsupported
ostream0.3220.3350.3210.3230unsupported
queue0.2350.2430.2350.2350.233unsupported
random0.3950.4070.3940.394unsupportedunsupported
rangeserrorunsupportedunsupportedunsupportedunsupportedunsupported
ratio0.0630.0640.0620.063unsupportedunsupported
regex0.5060.530.5050.505unsupportedunsupported
scoped_allocator0.1980.20.1980.198unsupportedunsupported
set0.2180.2260.2170.2170.215unsupported
setjmp.h0.0070.0050.0060.0070.0050.006
shared_mutex0.3790.4180.3790.3790.3770.379
signal.h0.0080.0070.0080.0080.0060.008
spanerrorunsupportedunsupportedunsupportedunsupportedunsupported
sstream0.4150.4420.4160.4250.414unsupported
stack0.2160.2240.2160.2160.214unsupported
stdarg.h0.0060.0050.0070.0060.0040.006
stddef.h0.0070.0080.0080.0080.0060.008
stdexcept0.2070.2150.2080.2070.205unsupported
stdint.h0.0060.0060.0060.0060.0050.006
stdio.h0.0420.0410.0420.0420.040.042
stdlib.h0.0170.0170.0180.020.0160.017
streambuf0.3110.3250.3110.3130.309unsupported
string0.4130.4390.4130.4150.412unsupported
string_viewerror0.343unsupportedunsupportedunsupportedunsupported
string.h0.0160.0160.0170.0170.0150.017
strstream0.360.3750.3580.360.357unsupported
syncstreamerrorunsupportedunsupportedunsupportedunsupportedunsupported
system_error0.2490.2560.2460.247unsupportedunsupported
thread0.290.3370.2890.291unsupportedunsupported
time.h0.0110.010.0120.0120.010.011
tuple0.1620.1650.1630.163unsupportedunsupported
type_traitserror0.0640.060.064unsupportedunsupported
typeindex0.0060.0730.0690.07unsupportedunsupported
typeinfo0.0680.070.0680.0680.067unsupported
uchar.h0.0080.0080.0090.0080.0060.008
unordered_map0.2450.2530.2450.245unsupportedunsupported
unordered_set0.2310.2390.2310.232unsupportedunsupported
utility0.1250.1280.1270.1260.124unsupported
valarray0.1980.20.1980.1980.197unsupported
varianterror0.223unsupportedunsupportedunsupportedunsupported
vector0.2180.2260.2170.2170.216unsupported
versionerrorunsupportedunsupportedunsupportedunsupportedunsupported
wchar.h0.0450.0420.0430.0430.0410.043
wctype.h0.0090.0080.0080.0090.0070.01
windows.h0.5160.5160.5170.5210.5190.519

clang

Headerc++20c++17c++14c++11c++03c++98
algorithm0.3210.3220.316errorerrorunsupported
any0.320.324unsupportedunsupportedunsupportedunsupported
array0.5270.5270.506errorunsupportedunsupported
assert.h0.0110.0130.0140.0160.0160.017
atomic0.6640.6680.659errorunsupportedunsupported
biterrorunsupportedunsupportedunsupportedunsupportedunsupported
bitset0.5490.550.527errorerrorunsupported
cassert0.0150.0190.0170.018errorunsupported
cctype0.020.0210.0230.024errorunsupported
cerrno0.0150.0160.0180.019errorunsupported
cfenv0.0190.0210.0220.022unsupportedunsupported
cfloat0.0160.0180.0190.02errorunsupported
charconverrorerrorunsupportedunsupportedunsupportedunsupported
chrono0.3040.3060.306errorunsupportedunsupported
cinttypes0.0180.0190.0210.021unsupportedunsupported
climits0.0150.0160.0180.019errorunsupported
clocale0.0160.0170.0190.019errorunsupported
cmath00.0820.0840.087errorunsupported
codecvtunsupported 0.569 0.542 errorunsupportedunsupported
compareerrorunsupportedunsupportedunsupportedunsupportedunsupported
complexerror0.5820.558errorerrorunsupported
conceptserrorunsupportedunsupportedunsupportedunsupportedunsupported
condition_variable0.5670.5690.51errorunsupportedunsupported
contracterrorunsupportedunsupportedunsupportedunsupportedunsupported
csetjmp0.0150.0160.0180.019errorunsupported
csignal0.0150.0160.0170.019errorunsupported
cstdarg0.0140.0160.0180.019errorunsupported
cstddef0.020.0220.0210.023errorunsupported
cstdint0.0160.0170.0180.02unsupportedunsupported
cstdio0.0710.0710.0730.074errorunsupported
cstdlib0.0550.0560.0580.059errorunsupported
cstring0.0350.0360.0380.039errorunsupported
ctime0.0220.0230.0250.025errorunsupported
ctype.h0.0170.0180.020.0210.0220.022
cuchar0.0150.0170.0180.018unsupportedunsupported
cwchar0.0790.080.0820.083errorunsupported
cwctype0.0180.0190.020.021errorunsupported
deque0.3570.3590.339errorerrorunsupported
errno.h0.0120.0140.0150.0160.0160.018
exception0.1060.1080.103errorerrorunsupported
executionerrorerrorunsupportedunsupportedunsupportedunsupported
fenv.h0.0150.0170.0180.0190.020.021
filesystem 0.873 0.875unsupportedunsupportedunsupportedunsupported
float.h0.0130.0140.0160.0170.0180.018
forward_list0.3550.3570.338errorunsupportedunsupported
fstream0.4950.4970.476errorerrorunsupported
functional0.4490.450.361errorerrorunsupported
future1.5081.5091.474errorunsupportedunsupported
initializer_list0.0210.0230.0220.023unsupportedunsupported
inttypes.h0.0140.0150.0160.0180.0180.019
iomanip0.5030.5040.482errorerrorunsupported
ios0.4750.4770.456errorerrorunsupported
iosfwd0.1710.1720.172errorerrorunsupported
iostream0.4840.4850.464errorerrorunsupported
istream0.4840.4860.463errorerrorunsupported
iterator0.4890.4910.468errorerrorunsupported
limits0.1620.1640.163errorerrorunsupported
limits.h0.010.0110.0120.0140.0140.015
list0.3550.3570.338errorerrorunsupported
locale0.5680.570.545errorerrorunsupported
locale.h0.0130.0140.0160.0180.0180.018
map0.3810.3820.363errorerrorunsupported
math.h0.0280.030.030.0320.0330.033
memory0.3290.3310.324errorerrorunsupported
memory_resourceerrorerrorunsupportedunsupportedunsupportedunsupported
mutex0.5540.5550.498errorunsupportedunsupported
new0.1070.1090.106errorerrorunsupported
numericerror0.2440.236errorerrorunsupported
optional0.3250.327unsupportedunsupportedunsupportedunsupported
ostream0.480.480.459errorerrorunsupported
queue0.3930.3950.374errorerrorunsupported
random0.5710.5750.553errorunsupportedunsupported
rangeserrorunsupportedunsupportedunsupportedunsupportedunsupported
ratio0.1050.1060.103errorunsupportedunsupported
regex0.6560.6590.634errorunsupportedunsupported
scoped_allocator0.3280.330.323errorunsupportedunsupported
set0.360.3620.341errorerrorunsupported
setjmp.h0.010.0110.0130.014errorerror
shared_mutex0.5670.5680.508errorerrorerror
signal.h0.0120.0130.0150.0160.0170.017
spanerrorunsupportedunsupportedunsupportedunsupportedunsupported
sstream0.550.5520.528errorerrorunsupported
stack0.360.3620.341errorerrorunsupported
stdarg.h0.0030.0040.0060.0070.0080.008
stddef.h0.0040.0050.0070.0080.0080.009
stdexcept0.3480.3510.33errorerrorunsupported
stdint.h0.010.0110.0130.0140.0150.015
stdio.h0.0670.0680.0690.0710.0710.072
stdlib.h0.0350.0370.0390.040.040.041
streambuf0.4660.4660.444errorerrorunsupported
string0.5450.5470.523errorerrorunsupported
string_view0.4820.484unsupportedunsupportedunsupportedunsupported
string.h0.0320.0330.0340.0360.0370.037
strstream0.5130.5150.492errorerrorunsupported
syncstreamerrorunsupportedunsupportedunsupportedunsupportedunsupported
system_error0.3840.3860.365errorunsupportedunsupported
thread0.5090.5110.448errorunsupportedunsupported
time.h0.0190.0210.0220.0230.0240.025
tuple0.2680.270.263errorunsupportedunsupported
type_traits0.0980.10.096errorunsupportedunsupported
typeindex0.1110.1130.109errorunsupportedunsupported
typeinfo0.1090.110.107errorerrorunsupported
uchar.h0.0120.0130.0150.017errorerror
unordered_map0.4020.4040.384errorunsupportedunsupported
unordered_set0.3840.3850.365errorunsupportedunsupported
utility0.2140.2190.212errorerrorunsupported
valarrayerror0.3260.319errorerrorunsupported
variant0.3760.377unsupportedunsupportedunsupportedunsupported
vector0.3620.3630.344errorerrorunsupported
versionerrorunsupportedunsupportedunsupportedunsupportedunsupported
wchar.h0.0750.0770.0780.080.080.081
wctype.h0.0140.0160.0170.0190.0190.02
windows.h1.0541.0551.0381.034errorerror

Heuristics

The data here is provided to show reasonable confidence in the above numbers. I won’t be posting this type of data for everything as it’s just a ton of numbers to walk through. If you need or want this data, contact me on twitter @virtuallyrandom.

Bell curve data is divided into standard deviations. The count of hits within each are then counted to give the “Confidence” column, which is simply the percent of things in that bucket (number_of_things_in_bucket / total_number_of_things.) As the range increases, so does the confidence.

Each confidence percentage is followed by a range. As the range is increase, the confidence rating does as well. With 128 tests and a range of 5 milliseconds, the results are mostly around 90%, except for clang which has a wider variation. With 256 tests, we get to 92-94%, but the tests take twice as long.

Below is the bell curve for assert.h, VC15, C++14. They all pretty much follow this same pattern where there is a very high occurrence count at a small time interval with a few deviations outside of that.

HeaderCompilerStandardAverageDeviationPercent 1Range Start 1Range Stop 1Percent 3Range Start 3Range Stop 3Percent 5Range Start 5Range Stop 5
assert.hVS15c++140.0089060.00146.90%0.0870.08886.70%0.0860.08996.10%0.0850.09
assert.hVS15c++110.0096740.00136.70%0.0880.08982.00%0.0870.0996.90%0.0860.091
assert.hVS15c++030.0095690.00135.90%0.0880.08980.50%0.0870.0996.90%0.0860.091
assert.hVS15c++980.0098640.00142.20%0.0880.08982.80%0.0870.0996.10%0.0860.091
assert.hVS17c++200.0070730.00132.80%0.0840.08580.50%0.0830.08696.10%0.0820.087
assert.hVS17c++170.0066310.00132.80%0.0840.08571.90%0.0830.08689.80%0.0820.087
assert.hVS17c++140.007750.00129.70%0.0840.08564.80%0.0830.08689.10%0.0820.087
assert.hVS17c++110.0077330.00122.70%0.0850.08660.20%0.0840.08785.90%0.0830.088
assert.hVS17c++030.0056950.00125.80%0.0860.08764.10%0.0850.08896.90%0.0840.089
assert.hVS17c++980.006820.00124.20%0.0850.08665.60%0.0840.08785.90%0.0830.088
assert.hclangc++200.0111840.00129.70%0.1030.10462.50%0.1020.10581.30%0.1010.106
assert.hclangc++170.0129670.00125.80%0.1050.10662.50%0.1040.10784.40%0.1030.108
assert.hclangc++140.0143250.00122.70%0.1070.10851.60%0.1060.10975.80%0.1050.11
assert.hclangc++110.0157950.00123.40%0.1080.10953.10%0.1070.1171.10%0.1060.111
assert.hclangc++030.0155880.00121.90%0.1070.10850.80%0.1060.10978.90%0.1050.11
assert.hclangc++980.0168760.00121.10%0.1090.1155.50%0.1080.11168.80%0.1070.112

If you got this far, good job! In the next post, I’m going to delve into things you can do to affect compile times, hopefully for the better!

Upon request, I’ve uploaded the tab delimited text results of the tests.

  • output.txt – contains the speed of the processor that ran the tests followed by the name and compilation time for each header on each compiler for each standard.
  • bell.txt – contains the header, compiler, standard, average deviation, percent and range followed by column of data that contain the count of times within that range.
  • time.txt – contains the header, compiler, standard, base time (in clocks) for the empty test, followed by the time per iteration of the test in clock cycles.

Edit: I found a typo in the test data which caused codecvt and filesystem headers to be marked as unsupported. I have since fixed it and uploaded an addendum to the test results.

C++ Compilation: Lies, Damned Lies, and Statistics
Tagged on:                 

4 thoughts on “C++ Compilation: Lies, Damned Lies, and Statistics

  • January 17, 2019 at 8:56 pm
    Permalink

    Is your data available for download (a csv would be good)?

    I’m happy to throw some more statistics at it. Ought to be able to extract a bit more information than is in the tables.

    Reply
  • January 18, 2019 at 2:48 pm
    Permalink

    Thanks. Let’s fit a regression model to time.txt

    # Some R code
    library(“lme4”)
    library(“reshape2”)

    # I have added a header ito the data
    w_vr=read.csv(paste0(ESEUR_dir, “benchmark/virt-random/time.txt”), as.is=TRUE, sep=”\t”)

    vr=melt(w_vr, id.vars=c(“header”, “compiler”, “language”, “empty_test”), value.name=”time”)

    # unique(vr$compiler)
    # [1] “VS15” “VS17” “clang”
    # table(vr$compiler, vr$language)
    # c++03 c++11 c++14 c++17 c++20 c++98
    # clang 2451 5676 12384 12900 12513 2451
    # VS15 9417 12384 12384 0 0 2967
    # VS17 9417 12384 12384 12900 12255 2967

    vr_mod=glm(time ~ header+compiler*language, data=vr)
    summary(vr_mod)

    The following is a cut down version of the summary output (only a few headers are listed), and I have normalised the numbers.

    The algorithm to calculate normalised time from these values is:

    1+header_value+compiler_value+language_value
    The default compiler is clang and the default language is c++03.
    So the time for:
    wchar.h using clang, with c++03 is: 1-0.514807638
    wchar.h using clang with c++14 is 1-0.514807638+0.158299933
    wchar.h using VS15 with c++11 is 1-0.514807638-0.183862162 +0.033951731-0.059720131

    Enjoy:

    headervector headerwchar.h
    0.082927784 -0.514807638
    headerwctype.h headerwindows.h
    -0.648127718 1.304057019
    compilerVS15 compilerVS17
    -0.183862162 -0.128181421
    languagec++11 languagec++14
    0.033951731 0.158299933
    languagec++17 languagec++20
    0.194170981 0.181542383
    languagec++98 compilerVS15:languagec++11
    0.001149537 -0.059720131
    compilerVS17:languagec++11 compilerVS15:languagec++14
    -0.024050781 -0.185808250
    compilerVS17:languagec++14 compilerVS15:languagec++17
    -0.150414434 NA
    compilerVS17:languagec++17 compilerVS15:languagec++20
    -0.167972732 NA
    compilerVS17:languagec++20 compilerVS15:languagec++98
    -0.177197657 0.060489284
    compilerVS17:languagec++98
    0.028155402

    Reply
  • Pingback:The Shape of Code » Modeling visual studio C++ compile times

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.