C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Benchmarking Including The C++ Standard Library

From: Adrian Johnston <ajohnston4536_at_[hidden]>
Date: Sat, 16 May 2026 17:40:05 -0700
>> These are both outdated, unsupported releases, without full C++20 or
C++23 support.
>> You're going to faint when you see the size of <vector> in GCC 16 for
C++26.

Johnathan: I just updated to the very latest non-LTS Ubuntu and you are
right, the numbers are a lot worse. I am still a couple versions behind. If
someone has the latest compilers built and wants to run that script and
post the numbers that would be interesting. For some reason C++11 support
is even getting slower. Off hand, my only explanation is that the compilers
have a lot more complexity now due to additional features.

(I have an array class that does even more with less:
https://github.com/whatchamacallem/libhatchet/blob/main/include/hx/hxarray.hpp
)

>> A couple of concerns regarding the methodology. First: using only 2 of
the 3 "big"
>> compilers. Second: using versions of the compilers that are 2 and 4
major versions
>> behind. And third: not comparing against "import std;".

Andre: MSVC results are below. It is 100ms faster than GCC at compiling the
selected headers. Microsoft seems to be memory imaging the PCH and loading
it in ~4 ms which is impressive... (Or a mistake on my part. As an old
video games programmer I think everything perf related should be a memory
image, ideally memory mapped at that.)

Again, here is the latest version of my script if you want to check my
work: https://github.com/whatchamacallem/cxx-std-include-bench/

Finally, modules are just landing now so it is hard to give you comparisons
with historical versions of their implementation. If the intention is to
tell all users to switch to using modules if they are moving to C++20 and
later, that might not be the worst considering these numbers.


# Updated Numbers

| Compiler | Version | | Startup (ms) |
|----------|----------------------------------------|--------------:|
| GCC | g++ (Ubuntu 15.2.0-4ubuntu4) 15.2.0 | 22 |
| Clang | Ubuntu clang version 20.1.8 (0ubuntu4) | 23 |

## Compilation Time

| Standard | GCC LOC | GCC ms (net) | Clang LOC | Clang ms (net) |
|----------|--------:|-------------:|----------:|---------------:|
| C++11 | 75473 | 432 | 63666 | 759 |
| C++14 | 77209 | 476 | 65102 | 827 |
| C++17 | 85540 | 516 | 71479 | 880 |
| C++20 | 112913 | 1001 | 84360 | 1363 |
| C++23 | 128846 | 1175 | 87186 | 1598 |

## Compilation Time Using A Precompiled Header

| Standard | GCC PCH ms (net) | Clang PCH ms (net) |
|----------|-----------------:|-------------------:|
| C++11 | 69 | 88 |
| C++14 | 69 | 91 |
| C++17 | 85 | 130 |
| C++20 | 352 | 135 |
| C++23 | 367 | 138 |

## MSVC Compilation Time

| Standard | MSVC LOC | MSVC ms (net) |
|----------|--------:|--------------:|
| C++14 | 76450 | 342 |
| C++17 | 80143 | 392 |
| C++20 | 106817 | 907 |
| C++23 | 119710 | 1013 |

## MSVC Compilation Time Using A Precompiled Header

| Standard | MSVC PCH ms (net) |
|----------|------------------:|
| C++14 | 3 |
| C++17 | 3 |
| C++20 | 4 |
| C++23 | 5 |

Received on 2026-05-17 00:40:18