instrumentation: Rename userTime and systemTime fields to exclude units

Drop the "USec" suffix from these fields for consistency with other
instrumentation fields which do not include units.
This commit is contained in:
Martin Duffy
2026-09-17 10:10:31 -04:00
parent 833d9466d7
commit 68e2a3e793
6 changed files with 20 additions and 20 deletions
+4 -4
View File
@@ -607,10 +607,10 @@ Snippet files have a filename with the syntax
``maxRSS``
Maximum resident set size in KiB.
``userTimeUSec``
``userTime``
User CPU time in microseconds.
``systemTimeUSec``
``systemTime``
System CPU time in microseconds.
If the data could not be collected, this object is ``null``.
@@ -660,8 +660,8 @@ Example:
"processMetrics" :
{
"maxRSS" : 21032,
"userTimeUSec" : 18000,
"systemTimeUSec" : 5000
"userTime" : 18000,
"systemTime" : 5000
},
"timeStart" : 1737053448177,
"duration" : 31,
@@ -400,8 +400,8 @@
"type": "object",
"required": [
"maxRSS",
"userTimeUSec",
"systemTimeUSec"
"userTime",
"systemTime"
],
"properties": {
"maxRSS": {
@@ -409,12 +409,12 @@
"description": "Maximum resident set size reported for wrapped child processes, in KiB.",
"minimum": 0
},
"userTimeUSec": {
"userTime": {
"type": "integer",
"description": "User CPU time reported for wrapped child processes, in microseconds.",
"minimum": 0
},
"systemTimeUSec": {
"systemTime": {
"type": "integer",
"description": "System CPU time reported for wrapped child processes, in microseconds.",
"minimum": 0
+2 -2
View File
@@ -403,10 +403,10 @@ void cmCTestLaunch::WriteMetricsFile() const
Json::Value processMetrics(Json::objectValue);
processMetrics["maxRSS"] =
static_cast<Json::Value::UInt64>(this->ChildResourceUsage->ru_maxrss);
processMetrics["userTimeUSec"] = static_cast<Json::Value::UInt64>(
processMetrics["userTime"] = static_cast<Json::Value::UInt64>(
this->ChildResourceUsage->ru_utime.tv_sec * 1000000ULL +
this->ChildResourceUsage->ru_utime.tv_usec);
processMetrics["systemTimeUSec"] = static_cast<Json::Value::UInt64>(
processMetrics["systemTime"] = static_cast<Json::Value::UInt64>(
this->ChildResourceUsage->ru_stime.tv_sec * 1000000ULL +
this->ChildResourceUsage->ru_stime.tv_usec);
root["processMetrics"] = std::move(processMetrics);
+2 -2
View File
@@ -1175,8 +1175,8 @@ void cmCTestRunTest::FinalizeTest(bool started)
ProcessMetrics usage{};
Json::Value const& processMetrics = root["processMetrics"];
usage.ru_maxrss = processMetrics["maxRSS"].asLargestUInt();
auto userUSec = processMetrics["userTimeUSec"].asLargestUInt();
auto systemUSec = processMetrics["systemTimeUSec"].asLargestUInt();
auto userUSec = processMetrics["userTime"].asLargestUInt();
auto systemUSec = processMetrics["systemTime"].asLargestUInt();
usage.ru_utime.tv_sec = static_cast<long>(userUSec / 1000000ULL);
usage.ru_utime.tv_usec = static_cast<long>(userUSec % 1000000ULL);
usage.ru_stime.tv_sec = static_cast<long>(systemUSec / 1000000ULL);
+2 -2
View File
@@ -1272,9 +1272,9 @@ Json::Value cmInstrumentation::ResourceUsageToJSON(ProcessMetrics const& usage)
{
Json::Value root(Json::objectValue);
root["maxRSS"] = static_cast<Json::Value::UInt64>(usage.ru_maxrss);
root["userTimeUSec"] = static_cast<Json::Value::UInt64>(
root["userTime"] = static_cast<Json::Value::UInt64>(
usage.ru_utime.tv_sec * 1000000ULL + usage.ru_utime.tv_usec);
root["systemTimeUSec"] = static_cast<Json::Value::UInt64>(
root["systemTime"] = static_cast<Json::Value::UInt64>(
usage.ru_stime.tv_sec * 1000000ULL + usage.ru_stime.tv_usec);
return root;
}
@@ -36,8 +36,8 @@ foreach(snippet IN LISTS snippets)
json_has_key("${snippet}" "${contents}" processMetrics)
string(JSON process_metrics GET "${contents}" processMetrics)
json_has_key("${snippet}" "${process_metrics}" maxRSS)
json_has_key("${snippet}" "${process_metrics}" userTimeUSec)
json_has_key("${snippet}" "${process_metrics}" systemTimeUSec)
json_has_key("${snippet}" "${process_metrics}" userTime)
json_has_key("${snippet}" "${process_metrics}" systemTime)
set(process_metrics_case "")
if (filename MATCHES "^custom-")
string(JSON outputs ERROR_VARIABLE noOutputs GET "${contents}" outputs)
@@ -47,10 +47,10 @@ foreach(snippet IN LISTS snippets)
set(process_metrics_case "cpu")
endif()
elseif (filename MATCHES "^test-")
string(JSON user_time_usec GET "${process_metrics}" userTimeUSec)
string(JSON user_time_usec GET "${process_metrics}" userTime)
if (user_time_usec LESS 0)
json_error("${snippet}"
"Expected process-metrics test userTimeUSec >= 0, got: ${user_time_usec}"
"Expected process-metrics test userTime >= 0, got: ${user_time_usec}"
)
endif()
string(JSON test_name GET "${contents}" testName)
@@ -78,8 +78,8 @@ foreach(snippet IN LISTS snippets)
)
endif()
elseif (process_metrics_case STREQUAL "cpu")
string(JSON user_time_usec GET "${process_metrics}" userTimeUSec)
string(JSON system_time_usec GET "${process_metrics}" systemTimeUSec)
string(JSON user_time_usec GET "${process_metrics}" userTime)
string(JSON system_time_usec GET "${process_metrics}" systemTime)
math(EXPR total_cpu_usec "${user_time_usec} + ${system_time_usec}")
if (total_cpu_usec LESS 10000)
json_error("${snippet}"