diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
| commit | 69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch) | |
| tree | ebc98370a697a9bbd6b973a14fa5113c475c6db7 /PerformanceTrace.hpp | |
| parent | 3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff) | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg'
with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'PerformanceTrace.hpp')
| -rw-r--r-- | PerformanceTrace.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/PerformanceTrace.hpp b/PerformanceTrace.hpp new file mode 100644 index 00000000..81ff56a2 --- /dev/null +++ b/PerformanceTrace.hpp @@ -0,0 +1,54 @@ +#ifndef PERFORMANCE_TRACE_HPP_ +#define PERFORMANCE_TRACE_HPP_ + +#include <QtGlobal> +#include <QString> + +namespace PerformanceTrace +{ + using RunId = quint64; + + // Measurements use one process-wide monotonic clock and are logged at INFO + // severity. The functions are thread-safe, but an individual Phase object + // must remain on one thread. Runs are retained until process exit so delayed + // asynchronous milestones can still be attributed to their originating run. + // Enable WSJT-X Diagnostic logging to capture the emitted "PERF" records. + + // A run groups related measurements on a shared monotonic timeline. The + // category and kind are emitted verbatim, so keep them stable and free of + // whitespace for log analysis. Records identify milestones, timed phases, + // and run ends explicitly through the event field. + RunId begin_run (char const * category, char const * kind); + RunId current_run (); + void finish_run (RunId run, char const * phase, QString const& details = {}); + qint64 elapsed_ms (); + + // Pass an explicit run from asynchronous work. current_run() may refer to a + // newer operation by the time a worker thread or queued callback completes. + // A finished run still accepts such explicitly attributed measurements. + void milestone (char const * phase, QString const& details = {}); + void milestone (RunId run, char const * phase, QString const& details = {}); + + // Phase records its duration when destroyed. Call finish() when details must + // accompany the measurement; subsequent calls and destruction are no-ops. + class Phase final + { + public: + explicit Phase (char const * phase); + Phase (RunId run, char const * phase); + ~Phase () noexcept; + + Phase (Phase const&) = delete; + Phase& operator= (Phase const&) = delete; + + void finish (QString const& details = {}); + + private: + RunId run_; + QString phase_; + qint64 started_ms_; + bool finished_ {false}; + }; +} + +#endif |
