A C++ Header-Only Runtime Performance Analysis Library
[TOC]
Simple Runtime Analyzer is a header-only C++ library for precise runtime performance profiling and benchmarking. It provides a modern, type-safe API to measure and analyze the execution time of functions and algorithms across varying input sizes.
Engineered with C++23 features, Simple Runtime Analyzer offers a streamlined workflow: from generating customizable sample data and collecting high-resolution timing metrics, to exporting detailed reports in multiple formats (TXT, CSV, JSON). Its modular design decouples measurement from reporting, making it an ideal tool for embedding performance analysis directly into unit tests, CI pipelines, or research projects.
The Simple Runtime Analyzer was born from a desire to create a reproducible and modular tool for measuring execution time using std::chrono. Beyond its benchmarking capabilities, the library is designed as an educational tool to demonstrate algorithmic complexity and real-world runtime behavior across varying input sizes.
This library provides a set of powerful utilities to streamline your performance analysis.
- β±οΈ Chrono-Based High-Precision Measurement: Template-driven timing infrastructure supporting all std::chrono duration units (nanoseconds to hours) for type-safe, flexible benchmarking.
- π Statistical Runtime Profiling: Automatically profile functions over a range of input sizes with configurable distribution (logarithmic or linear) for comprehensive performance analysis.
- π’ Smart Sample Generation: Generate optimized sample datasets with size biasing and rounding controls to stress-test algorithms under realistic conditions.
- πΎ Multi-Format Extensible Reporting: Export detailed results in human-readable (TXT), structured (CSV), or machine-readable (JSON) formats for seamless integration with external tools.
- π Built-In Python Visualization Tool: Includes a dedicated script for generating plots and charts from exported data using matplotlib for immediate insight.
- ποΈ Header-Only Modular Design: Zero-compilation overhead with a decoupled architecture that separates measurement, sampling, and reporting for easy integration and customization.
- π― Modern C++23 Compliance: Leverages concepts, ranges, and type traits for a safe, expressive, and compile-time validated API.
- Runtime Analyzer: Core timing and profiling functionality
- Runtime Reporter: Multi-format report generation
- Sample Utilities: Sample generation and serialization
- Plot Tool: Data visualization and graphing
- [.txt](\ref txt_format) Text Format
- [.csv](\ref csv_format) CSV Format
- [.json](\ref json_format) JSON Format
- [.png](\ref png_format) Plot Tool Output
The example.cpp file provides a complete, working example of how to use the Simple Runtime Analyzer library. This file demonstrates a full performance analysis workflow, from generating test data and profiling an algorithm to reporting the results and generating a visual plot. You can find this example at the following path:
example/src/example.cpp
- C++23 compatible compiler
- Python 3.6+ with the
matplotliblibrary (for visualization)
Since the Simple Runtime Analyzer is a header-only library, it's very easy to use and requires no pre-compilation or installation. You can get the latest version of the headers here: releases.
To use the library's components in your code, simply include the necessary header files. All functions and structures are located within the sra namespace.
#include "shineknightdev/runtime_analyzer.hpp"
#include "shineknightdev/runtime_reporter.hpp"
#include "shineknightdev/sample_utilities.hpp"Once you've generated reports using the C++ library, you can visualize them with the plot.py script from the command line. Simply pass the report files as arguments.
python plot.py output_file_1.json output_file_2.csvsimple-runtime-analyzer
ββ .clang-format
ββ .clang-tidy
ββ CMakeLists.txt
ββ CODE_OF_CONDUCT.md
ββ docs/
ββ Doxyfile
ββ LICENSE.md
ββ README.md
ββ example
β ββ src
β ββ example.cpp
ββ include
β ββ shineknightdev
β ββ runtime_analyzer.hpp
β ββ runtime_reporter.hpp
β ββ sample_utilities.hpp
ββ scripts
ββ plot.py# Configure with documentation enabled
cmake -B build -S . -DBUILD_DOCUMENTATION=ON
# Build everything
cmake --build build
# Generate documentation
cmake --build build --target docs
# Run example
cmake --build build --target example_runFor a comprehensive overview of the library, including a detailed API reference for each module, please visit the official documentation website.
https://shineknightdev.github.io/simple-runtime-analyzer
If you like the project and it seems useful, consider give a star βοΈ to the repository to show your support and Follow me on Github To be aware of my new projects. I appreciate all kinds of contributions. Whether you are reporting an error, suggesting a new feature or sending a change of code, your help is valuable.
βοΈ Code of Conduct A set of rules to ensure the community remains a welcoming and inclusive place.
π·π»ββοΈ Contributing Guide Details on how to get started, including how to report bugs, suggest features, and submit your first pull request.
πΈ Sponsor If you find this Toolkit useful, you can support me by sponsoring new projects.
π This project is licensed under the MIT License Β© 2025 Diego Osorio (ShineKnightDev).
| Read Next |
|---|
| Usage Notes |
