An early benchmark analysis of C++26 reflection's compile-time overhead using GCC 16. Key findings: the -freflection flag itself adds zero overhead, but including the <meta> header costs ~155ms per translation unit. Standard Library headers like <print> and <ranges> are the real bottleneck, not the reflection logic itself. Precompiled headers (PCH) are effectively mandatory for scaling, cutting AoS-to-SoA compile times from 818ms down to 113ms. C++ modules currently underperform PCH for smaller headers but are comparable for large ones like <print>. The author also notes a correction from an earlier version where a debug-build GCC Docker image inflated all numbers by ~40-50%.

10m read timeFrom vittorioromeo.com
Post cover image
Table of contents
let’s measure!benchmark resultsinsightswhat about modules?conclusionshameless self-promotionappendix: previous benchmark results

Sort: