File indexing completed on 2025-01-30 10:12:04
0001
0002
0003
0004
0005 #ifndef JANA2_JTESTDISENTANGLER_H
0006 #define JANA2_JTESTDISENTANGLER_H
0007
0008 #include <JANA/JFactoryT.h>
0009 #include <JANA/JEvent.h>
0010 #include <JANA/Utils/JBenchUtils.h>
0011
0012 #include "JTestDataObjects.h"
0013 #include "JTestCalibrationService.h"
0014
0015
0016 class JTestDisentangler : public JFactoryT<JTestEventData> {
0017
0018 size_t m_cputime_ms = 20;
0019 size_t m_write_bytes = 500000;
0020 double m_cputime_spread = 0.25;
0021 double m_write_spread = 0.25;
0022 JBenchUtils m_bench_utils = JBenchUtils();
0023
0024 std::shared_ptr<JTestCalibrationService> m_calibration_service;
0025
0026 public:
0027
0028 void Init() override {
0029 auto app = GetApplication();
0030 assert (app != nullptr);
0031 app->SetDefaultParameter("jtest:disentangler_ms", m_cputime_ms, "Time spent during disentangling");
0032 app->SetDefaultParameter("jtest:disentangler_spread", m_cputime_spread, "Spread of time spent during disentangling");
0033 app->SetDefaultParameter("jtest:disentangler_bytes", m_write_bytes, "Bytes written during disentangling");
0034 app->SetDefaultParameter("jtest:disentangler_bytes_spread", m_write_spread, "Spread of bytes written during disentangling");
0035
0036
0037 m_calibration_service = app->GetService<JTestCalibrationService>();
0038 }
0039
0040 void Process(const std::shared_ptr<const JEvent> &aEvent) override {
0041
0042 m_bench_utils.set_seed(aEvent->GetEventNumber(), NAME_OF_THIS);
0043
0044 auto eed = aEvent->GetSingle<JTestEntangledEventData>();
0045 m_bench_utils.read_memory(*eed->buffer);
0046
0047
0048 m_calibration_service->getCalibration();
0049
0050
0051 m_bench_utils.consume_cpu_ms(m_cputime_ms, m_cputime_spread);
0052
0053
0054 auto ed = new JTestEventData;
0055 m_bench_utils.write_memory(ed->buffer, m_write_bytes, m_write_spread);
0056 Insert(ed);
0057 }
0058 };
0059
0060 #endif