File indexing completed on 2025-01-30 10:12:04
0001
0002
0003
0004
0005 #ifndef JTestEventProcessor_h
0006 #define JTestEventProcessor_h
0007
0008 #include <JANA/JApplication.h>
0009 #include <JANA/JEventProcessor.h>
0010 #include <JANA/Utils/JBenchUtils.h>
0011 #include "JTestTracker.h"
0012 #include <mutex>
0013
0014 class JTestPlotter : public JEventProcessor {
0015
0016 size_t m_cputime_ms = 0;
0017 size_t m_write_bytes = 1000;
0018 double m_cputime_spread = 0.25;
0019 double m_write_spread = 0.25;
0020 JBenchUtils m_bench_utils = JBenchUtils();
0021 std::mutex m_mutex;
0022
0023 public:
0024
0025 JTestPlotter() {
0026 SetPrefix("jtest:plotter");
0027 SetTypeName(NAME_OF_THIS);
0028 }
0029
0030 void Init() override {
0031 auto app = GetApplication();
0032 app->SetDefaultParameter("jtest:plotter_ms", m_cputime_ms, "Time spent during plotting");
0033 app->SetDefaultParameter("jtest:plotter_spread", m_cputime_spread, "Spread of time spent during plotting");
0034 app->SetDefaultParameter("jtest:plotter_bytes", m_write_bytes, "Bytes written during plotting");
0035 app->SetDefaultParameter("jtest:plotter_bytes_spread", m_write_spread, "Spread of bytes written during plotting");
0036 }
0037
0038 void Process(const std::shared_ptr<const JEvent>& event) override {
0039
0040 m_bench_utils.set_seed(event->GetEventNumber(), typeid(*this).name());
0041
0042 auto td = event->GetSingle<JTestTrackData>();
0043 m_bench_utils.read_memory(td->buffer);
0044
0045
0046 event->Get<JTestTracker::JTestTrackAuxilliaryData>();
0047
0048
0049 std::lock_guard<std::mutex> lock(m_mutex);
0050
0051
0052 m_bench_utils.consume_cpu_ms(m_cputime_ms, m_cputime_spread);
0053
0054
0055 auto hd = new JTestHistogramData;
0056 m_bench_utils.write_memory(hd->buffer, m_write_bytes, m_write_spread);
0057 event->Insert(hd);
0058 }
0059
0060 };
0061
0062 #endif
0063