Timepp is a simple yet powerful C++20 utility for measuring execution times of functions, statements, and code blocks. It provides an easy-to-use API to benchmark performance and gather statistical insights, including mean, median, min, and max execution times. A summary is printed automatically at the end of the program run (when static instances go out of scope).
- Measure execution time of statements, functions, and code blocks
- Automatically logs and summarizes execution statistics
- Provides mean, median, min, and max times
- Supports both inline and scoped timing measurements
- Uses high-resolution clock for accurate timing
Simply include timepp.hpp in your project:
#include "timepp.hpp"No additional dependencies are required.
Examples can be found in tpp-test.cpp
timest(std::cout << "Hello, World!" << std::endl);int result = timefn(my_function());timegb(some_expensive_operation());timepush("Computation Block");
// Your code here
timepop();#include "timepp.hpp"
void example_function() {
timepush("Example");
for (volatile int i = 0; i < 1000000; ++i); // Simulated workload
timepop();
}
int main() {
timest(std::cout << "Starting..." << std::endl);
timefn(example_function());
return 0;
}