A simple, fast, accurate single-header microbenchmarking library for C++11/14/17/20.
ankerl::nanobench is a single-header microbenchmarking library for C++ that enables developers to measure the performance of small code snippets with high accuracy and minimal overhead. It solves the problem of quickly and reliably benchmarking C++ code across different platforms and compiler versions, providing detailed metrics like execution time, instructions per cycle, and branch prediction efficiency.
C++ developers, performance engineers, and library authors who need to profile and optimize low-level code, compare algorithm implementations, or validate performance improvements in a controlled environment.
Developers choose ankerl::nanobench for its simplicity, speed, and accuracy—it compiles quickly, runs benchmarks up to 80 times faster than alternatives like Google Benchmark, and provides robust, deterministic results with comprehensive performance counters.
Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
As a single-header library, it can be integrated into any C++ project with a simple #include, avoiding complex build system dependencies and reducing setup time.
Benchmarks run up to 80 times faster than Google Benchmark, enabling rapid iteration and quick feedback loops, as documented in the performance comparison.
Provides comprehensive metrics like nanoseconds per operation, instructions per cycle, and branch prediction misses, offering deep insights into microarchitectural effects.
Includes error percentage calculations and warnings for unreliable results, ensuring data integrity and helping developers avoid misleading benchmarks.
Primarily designed for CPU-bound code snippets; it does not natively support benchmarking I/O, network, or memory allocation performance, restricting its scope.
Lacks features for benchmarking multi-threaded applications, requiring manual implementation of threading which can introduce measurement inaccuracies.
Outputs results in Markdown tables, which may not be easily integrable with modern data visualization tools or automated reporting systems without additional parsing.
nanobench is an open-source alternative to the following products: