From 5cc1fd35ab65c20171982c73bf9c639b04ec8efc Mon Sep 17 00:00:00 2001 From: Stephen Foulds Date: Fri, 18 Aug 2023 12:17:22 +0100 Subject: [PATCH 1/3] Remove \n from mac --- Metadata.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Metadata.cpp b/Metadata.cpp index 15ce2ce..5b4f149 100644 --- a/Metadata.cpp +++ b/Metadata.cpp @@ -90,7 +90,10 @@ std::string Metadata::Mac() const std::stringstream buffer; buffer << macFile.rdbuf(); - return buffer.str(); + std::string macStr = buffer.str(); + // Remove trailing \n + macStr.erase(std::remove(macStr.begin(), macStr.end(), '\n'), macStr.cend()); + return macStr; } std::string Metadata::ReportTimestamp() const From 5e209ba62358865e77cc11341b3cfc0bca4dc6c2 Mon Sep 17 00:00:00 2001 From: Stephen Foulds Date: Fri, 18 Aug 2023 12:37:12 +0100 Subject: [PATCH 2/3] Timestamp reformat --- Metadata.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Metadata.cpp b/Metadata.cpp index 5b4f149..07ec47f 100644 --- a/Metadata.cpp +++ b/Metadata.cpp @@ -98,13 +98,11 @@ std::string Metadata::Mac() const std::string Metadata::ReportTimestamp() const { - auto t = std::time(nullptr); - auto tm = *std::localtime(&t); + std::time_t t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + std::stringstream timeStream; + timeStream << std::put_time( std::localtime( &t ), "%FT%T%z" ); - std::stringstream buffer; - buffer << std::put_time(&tm, "%Y-%m-%d %H:%M:%S"); - - return buffer.str(); + return timeStream.str(); } long Metadata::Duration() const From d27a789a91077d310fdacf8af8d0cdab11242cac Mon Sep 17 00:00:00 2001 From: Stephen Foulds Date: Fri, 18 Aug 2023 12:37:22 +0100 Subject: [PATCH 3/3] Remove spaces in field names --- MemoryMetric.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/MemoryMetric.cpp b/MemoryMetric.cpp index 43bd974..efa77b8 100644 --- a/MemoryMetric.cpp +++ b/MemoryMetric.cpp @@ -29,9 +29,9 @@ MemoryMetric::MemoryMetric(Platform platform, std::shared_ptrsecond; measurement.AddDataPoint(memoryUsageKb); } else { - Measurement measurement("Memory Used KB"); + Measurement measurement("Memory_Used_KB"); measurement.AddDataPoint(memoryUsageKb); mContainerMeasurements.insert(std::make_pair(containerName, measurement)); } @@ -524,7 +524,7 @@ void MemoryMetric::GetBroadcomBmemUsage() if (itr == mBroadcomBmemMeasurements.end()) { // New region - Measurement measurement("Memory Usage (KB)"); + Measurement measurement("Memory_Usage_KB"); measurement.AddDataPoint(usageKb); mBroadcomBmemMeasurements.insert(std::make_pair(std::string(regionName), measurement)); } else { @@ -615,10 +615,10 @@ void MemoryMetric::CalculateFragmentation() } else { std::vector measurements = {}; for (int i = 0; i < (int) freePages.size(); i++) { - Measurement fp("Free Pages"); + Measurement fp("Free_Pages"); fp.AddDataPoint(freePages[i]); - Measurement frag("Fragmentation %"); + Measurement frag("Fragmentation_%"); frag.AddDataPoint(fragmentationPercent[i]); memoryFragmentation fragMeasurement(fp, frag); measurements.emplace_back(fragMeasurement); @@ -721,7 +721,7 @@ void MemoryMetric::GetGpuMemoryUsageBroadcom() measurement.Used.AddDataPoint(virtualMemNumBytes / (long double) 1024.0); } else { Process process(pid); - Measurement used("Memory Usage KB"); + Measurement used("Memory_Usage_KB"); used.AddDataPoint(virtualMemNumBytes / (long double) 1024.0); auto measurement = gpuMeasurement(process, used); @@ -773,7 +773,7 @@ void MemoryMetric::GetGpuMemoryUsageAmlogic() } else { Process process(pid); - Measurement used("Memory Usage KB"); + Measurement used("Memory_Usage_KB"); used.AddDataPoint(gpuBytes / (long double) 1024.0); auto measurement = gpuMeasurement(process, used);