From 581d68d7947fa7cf1788847abb45eb6293556787 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 9 Nov 2023 22:33:17 -0500 Subject: [PATCH] JTestPlotter: Add missing critical section and change default cputime to 0ms --- docs/Howto.md | 4 ++-- src/plugins/JTest/JTestPlotter.h | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/Howto.md b/docs/Howto.md index 8e29d3e47..55f37034c 100644 --- a/docs/Howto.md +++ b/docs/Howto.md @@ -115,10 +115,10 @@ jtest:tracker_ms | int | 200 | Time spent during tracking jtest:tracker_spread | double | 0.25 | Spread of time spent during tracking jtest:tracker_bytes | int | 1000 | Bytes written during tracking jtest:tracker_bytes_spread | double | 0.25 | Spread of bytes written during tracking -jtest:plotter_ms | int | 20 | Time spent during plotting +jtest:plotter_ms | int | 0 | Time spent during plotting jtest:plotter_spread | double | 0.25 | Spread of time spent during plotting jtest:plotter_bytes | int | 1000 | Bytes written during plotting -jtest:plotter_bytes_spread | int | 0.25 | Spread of bytes written during plotting +jtest:plotter_bytes_spread | double | 0.25 | Spread of bytes written during plotting diff --git a/src/plugins/JTest/JTestPlotter.h b/src/plugins/JTest/JTestPlotter.h index 6ce1617b5..53a250b77 100644 --- a/src/plugins/JTest/JTestPlotter.h +++ b/src/plugins/JTest/JTestPlotter.h @@ -8,13 +8,15 @@ #include #include #include "JTestTracker.h" +#include class JTestPlotter : public JEventProcessor { - size_t m_cputime_ms = 20; + size_t m_cputime_ms = 0; size_t m_write_bytes = 1000; double m_cputime_spread = 0.25; double m_write_spread = 0.25; + std::mutex m_mutex; public: @@ -42,6 +44,9 @@ class JTestPlotter : public JEventProcessor { // Read the extra data objects inserted by JTestTracker aEvent->Get(); + // Everything that happens after here is in a critical section + std::lock_guard lock(m_mutex); + // Consume CPU consume_cpu_ms(m_cputime_ms, m_cputime_spread);