Find Related products on Amazon

Shop on Amazon

Show HN: Single-Header Profiler for C++17

Published on: 2025-04-29 22:16:03

<- to README.md <- to implementation.hpp utl::profiler is single-include solution for localized profiling, it features simple macros to measure how much time is taken by a certain scope / expression / code segment. Profiler automatically builds a call graph for all profiled functions and prints a nicely formatted table for every thread. See examples. Key features: Below is an output example from profiling a JSON parser: Definitions // Profiling macros UTL_PROFILER_SCOPE (label); UTL_PROFILER (label); UTL_PROFILER_BEGIN (segment, label); UTL_PROFILER_END (segment); // Style options struct Style { std:: size_t indent = 2 ; bool color = true ; double cutoff_red = 0.40 ; // > 40% of total runtime double cutoff_yellow = 0.20 ; // > 20% of total runtime double cutoff_gray = 0.01 ; // < 1% of total runtime }; // Global profiler object struct Profiler { void print_at_exit ( bool value) noexcept ; void upload_this_thread (); std::string format_results ( const Style & style = Style {}); }; ... Read full article.