A simple framework for creating compile-time microbenchmarks to measure C++ template metaprogramming performance.
Metabench is a framework for creating compile-time microbenchmarks in C++. It measures how long it takes to compile specific pieces of code, which is crucial for identifying performance bottlenecks in metaprogramming-heavy libraries. By automating the generation and timing of code variations, it helps developers optimize compilation times.
C++ library developers, especially those working with template metaprogramming, who need to analyze and improve the compile-time performance of their code.
Metabench provides a simple, integrated solution for a niche but critical aspect of C++ development—compile-time performance. It eliminates manual effort in benchmarking, offers precise measurements of code segments, and integrates seamlessly with CMake, making it the go-to tool for metaprogramming performance analysis.
A simple framework for compile-time benchmarks
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Subtracts baseline compilation time by measuring code only within #ifdef METABENCH guards, providing precise isolation of benchmarked segments as described in the principle section.
Leverages ERB templates to automatically generate families of .cpp files with varying parameters, eliminating manual repetition in benchmark creation, as shown in the usage example.
Provided as a single CMake module (metabench.cmake), making it easy to drop into existing CMake-based projects without external dependencies, per the overview.
Outputs JSON files for easy integration with visualization tools and generates HTML charts with NVD3, automating data collection and presentation.
Requires Ruby 2.1 or higher for ERB template processing, adding an extra dependency that is not standard in many C++ toolchains and complicates setup.
Admits limited resolution similar to the 'time' command, making measurements unreliable for very short compilations unless code is artificially repeated, as noted in the benchmark resolution section.
Targeted solely at compile-time benchmarking for template metaprogramming, requiring understanding of ERB, CMake, and C++ metaprogramming, which can be overwhelming for general use.