File indexing completed on 2025-01-18 10:17:41
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 Parameter<size_t> m_cputime_ms {this, "cputime_ms", 20, "Time spent during disentangling" };
0019 Parameter<size_t> m_write_bytes {this, "bytes", 500000, "Bytes written during disentangling"};
0020 Parameter<double> m_cputime_spread {this, "cputime_spread", 0.25, "Spread of time spent during disentangling"};
0021 Parameter<double> m_write_spread {this, "bytes_spread", 0.25, "Spread of bytes written during disentangling"};
0022
0023 Service<JTestCalibrationService> m_calibration_service {this};
0024
0025 JBenchUtils m_bench_utils;
0026
0027 public:
0028
0029 JTestDisentangler() {
0030 SetPrefix("jtest:disentangler");
0031 SetTypeName(NAME_OF_THIS);
0032 }
0033
0034 void Process(const std::shared_ptr<const JEvent> &aEvent) override {
0035
0036 m_bench_utils.set_seed(aEvent->GetEventNumber(), NAME_OF_THIS);
0037
0038
0039 auto eed = aEvent->GetSingle<JTestEntangledEventData>();
0040 m_bench_utils.read_memory(*eed->buffer);
0041
0042
0043 auto calib = m_calibration_service->getCalibration();
0044
0045
0046 m_bench_utils.consume_cpu_ms(*m_cputime_ms + calib, *m_cputime_spread);
0047
0048
0049 auto ed = new JTestEventData;
0050 m_bench_utils.write_memory(ed->buffer, *m_write_bytes, *m_write_spread);
0051 Insert(ed);
0052 }
0053 };
0054
0055 #endif