![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Collects high-resolution timing data for labeled code sections. More...
#include <profiler.hpp>
Public Types | |
| using | time_point = std::chrono::high_resolution_clock::time_point |
| using | TimeCounter = std::pair<std::size_t, std::size_t> |
Static Public Member Functions | |
| static void | setEnabled (bool enabled) |
| Turn recording on or off (on by default), outside timed regions: a stop() without its start() records a wrong time. When off, start/stop with a literal label cost one branch. | |
| static void | start (const char *label) |
| start(label) when recording is on. | |
| static void | stop (const char *label) |
| stop(label) when recording is on. | |
| static void | startInterval (const char *label) |
| startInterval(label) when recording is on. | |
| static void | stopInterval (const char *label) |
| stopInterval(label) when recording is on. | |
| static void | start (const std::string &label) |
| Begin timing a single interval for the specified label. | |
| static void | startInterval (const std::string &label) |
| Mark the start of one interval among multiple for a label. | |
| static void | stop (const std::string &label) |
| End timing a single interval for the specified label. | |
| static void | stopInterval (const std::string &label) |
| End one interval among multiple for the specified label. | |
| static void | print () |
| Print accumulated timings for all labels in milliseconds. | |
| static void | clear () |
| Remove all recorded timing data. | |
| static nlohmann::json | dumpJson () |
| Export collected profile data as a JSON object including interval timestamps. | |
| static size_t | getDuration (const std::string &label) |
| Get the time elapsed for a certain label. | |
Static Public Attributes | |
| static bool | s_enabled = true |
| static std::unordered_map< std::string, TimeCounter > | time_map = {} |
| static std::unordered_map< std::string, time_point > | start_times = {} |
| Pending start time recorded per label via start(), consumed by stop(). | |
| static std::unordered_map< std::string, std::vector< time_point > > | stop_time_intervals = {} |
| Interval end timestamps recorded per label via stopInterval(). | |
| static std::unordered_map< std::string, std::vector< time_point > > | start_time_intervals = {} |
| Interval start timestamps recorded per label via startInterval(). | |
Collects high-resolution timing data for labeled code sections.
When NPROFILE is not defined, start/stop calls record durations in nanoseconds under a given label. Intervals support multiple start/stop pairs to measure repeated events. Accumulated times can be printed or cleared. A JSON dump method provides machine-readable output.
| using Profiler::time_point = std::chrono::high_resolution_clock::time_point |
| using Profiler::TimeCounter = std::pair<std::size_t, std::size_t> |
|
static |
Remove all recorded timing data.
|
static |
Export collected profile data as a JSON object including interval timestamps.
Structure: { "label": { "total_ns": uint64, "interval_starts_ns": [uint64, ...], "interval_ends_ns": [uint64, ...] }, ... }
|
static |
Get the time elapsed for a certain label.
|
static |
Print accumulated timings for all labels in milliseconds.
Outputs a table sorted by descending total time. Labels are left- aligned, and times are right-aligned with three decimal places.
|
inlinestatic |
|
inlinestatic |
start(label) when recording is on.
|
static |
Begin timing a single interval for the specified label.
| label | Unique identifier for the timed block. |
Records the current high-resolution clock time as the start point. Subsequent stop(label) call will add the elapsed time (in ns) to the cumulative total for this label.
|
inlinestatic |
startInterval(label) when recording is on.
|
static |
Mark the start of one interval among multiple for a label.
| label | Identifier grouping related intervals. |
Pushes the current high-resolution clock time onto a stack associated with the label. Each push should correspond to a matching stopInterval(label) to compute individual durations.
|
inlinestatic |
stop(label) when recording is on.
|
static |
End timing a single interval for the specified label.
| label | Label previously used with start(label). |
Calculates the time difference between now and the last start(label) call, then adds the duration (in ns) to the cumulative total.
|
inlinestatic |
stopInterval(label) when recording is on.
|
static |
End one interval among multiple for the specified label.
| label | Identifier matching a previous startInterval(label). |
Pushes the current time as the interval's end counterpart.
|
inlinestatic |
|
static |
Interval start timestamps recorded per label via startInterval().
|
static |
|
static |
Interval end timestamps recorded per label via stopInterval().
|
static |
Cumulative {total_duration_ns, call_count} recorded per label via start()/stop().