From c8345faab6d4b65656f51d2c826d1df0aa38970d Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sun, 11 Oct 2026 12:03:44 +0100 Subject: [PATCH] Profiler: Add PROFILER_ADD to measure things in other ways. --- sdrbase/util/profiler.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sdrbase/util/profiler.h b/sdrbase/util/profiler.h index 8bdcd9b7a..061767737 100644 --- a/sdrbase/util/profiler.h +++ b/sdrbase/util/profiler.h @@ -38,6 +38,8 @@ // // The parameters to PROFILER_STOP are: // name: Name for the code being profiled. Profiles using the same name are averaged. +// +// PROFILER_ADD(name, nanoSec) adds a duration measured some other way, such as how late something happened. #ifdef ENABLE_PROFILER #define PROFILER_START() \ @@ -45,20 +47,25 @@ profileTimer.start(); #define PROFILER_RESTART() \ profileTimer.start(); -#define PROFILER_STOP(name) \ +#define PROFILER_ADD(name, nanoSec) \ { \ - qint64 timeNanoSec = profileTimer.nsecsElapsed(); \ QHash& globalData = GlobalProfileData::getProfileData(); \ if (!globalData.contains(name)) { \ globalData.insert(name, ProfileData()); \ } \ ProfileData& profileData = globalData[name]; \ - profileData.add(timeNanoSec); \ + profileData.add(nanoSec); \ GlobalProfileData::releaseProfileData(); \ } +#define PROFILER_STOP(name) \ + { \ + qint64 timeNanoSec = profileTimer.nsecsElapsed(); \ + PROFILER_ADD(name, timeNanoSec) \ + } #else #define PROFILER_START() #define PROFILER_RESTART() +#define PROFILER_ADD(name, nanoSec) #define PROFILER_STOP(name) #endif