From 11f67d416aeacaecc07f34848a2b281886cb0016 Mon Sep 17 00:00:00 2001 From: Tyler Yankee Date: Thu, 25 Sep 2025 09:16:12 -0400 Subject: [PATCH] instrumentation: Use null when CPU load is unknown --- Help/manual/cmake-instrumentation.7.rst | 8 +++++--- Source/cmInstrumentation.cxx | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Help/manual/cmake-instrumentation.7.rst b/Help/manual/cmake-instrumentation.7.rst index a551212375..252a5235ba 100644 --- a/Help/manual/cmake-instrumentation.7.rst +++ b/Help/manual/cmake-instrumentation.7.rst @@ -410,13 +410,15 @@ and contain the following data: The Host Memory Used in KiB at ``timeStart``. ``afterHostMemoryUsed`` - The Host Memory Used in KiB at ``timeStop``. + The Host Memory Used in KiB at ``timeStart + duration``. ``beforeCPULoadAverage`` - The Average CPU Load at ``timeStart``. + The Average CPU Load at ``timeStart``, or ``null`` if it cannot be + determined. ``afterCPULoadAverage`` - The Average CPU Load at ``timeStop``. + The Average CPU Load at ``timeStart + duration``, or ``null`` if it cannot + be determined. ``configureContent`` The path to a :ref:`cmake_instrumentation Configure Content` file located diff --git a/Source/cmInstrumentation.cxx b/Source/cmInstrumentation.cxx index edc1c30eb3..6b635000d2 100644 --- a/Source/cmInstrumentation.cxx +++ b/Source/cmInstrumentation.cxx @@ -416,7 +416,8 @@ void cmInstrumentation::InsertDynamicSystemInformation( } root["dynamicSystemInformation"][cmStrCat(prefix, "HostMemoryUsed")] = memory; - root["dynamicSystemInformation"][cmStrCat(prefix, "CPULoadAverage")] = load; + root["dynamicSystemInformation"][cmStrCat(prefix, "CPULoadAverage")] = + load > 0 ? Json::Value(load) : Json::nullValue; } void cmInstrumentation::GetDynamicSystemInformation(double& memory,