Skip to content

Commit

Permalink
JTestPlotter: Add missing critical section and change default cputime…
Browse files Browse the repository at this point in the history
… to 0ms
  • Loading branch information
nathanwbrei committed Nov 10, 2023
1 parent 42b86a9 commit 581d68d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/Howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
7 changes: 6 additions & 1 deletion src/plugins/JTest/JTestPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#include <JANA/JApplication.h>
#include <JANA/JEventProcessor.h>
#include "JTestTracker.h"
#include <mutex>

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:

Expand Down Expand Up @@ -42,6 +44,9 @@ class JTestPlotter : public JEventProcessor {
// Read the extra data objects inserted by JTestTracker
aEvent->Get<JTestTracker::JTestTrackAuxilliaryData>();

// Everything that happens after here is in a critical section
std::lock_guard<std::mutex> lock(m_mutex);

// Consume CPU
consume_cpu_ms(m_cputime_ms, m_cputime_spread);

Expand Down

0 comments on commit 581d68d

Please sign in to comment.