17#include "benchmark/benchmark.h"
33 col.columnId = columnId;
34 col.setNonBendPattern(nbp);
35 col.setBendPattern(bp1, 0);
36 col.setBendPattern(bp2, 1);
37 col.setBendPattern(bp3, 2);
38 col.setBendPattern(bp4, 3);
42std::vector<uint8_t>
generateTestData(
size_t nTF,
size_t nDataInTF,
size_t nColDataInEvent,
size_t nLinks = o2::mid::crateparams::sNGBTs)
44 std::vector<o2::mid::ColumnData> colData;
45 colData.reserve(nColDataInEvent);
47 int nDEs = nColDataInEvent / maxNcols;
48 int nColLast = nColDataInEvent % maxNcols;
54 for (
int ide = 0; ide < nDEs; ++ide) {
55 int nCol = (ide == nDEs - 1) ? nColLast : maxNcols;
57 int firstCol = (rpcLine < 3 || rpcLine > 5) ? 0 : 1;
58 for (
int icol = firstCol; icol < nCol; ++icol) {
59 colData.emplace_back(
getColData(ide, icol, 0xFF00, 0xFF0));
63 auto severity = fair::Logger::GetConsoleSeverity();
64 fair::Logger::SetConsoleSeverity(fair::Severity::warning);
67 std::string tmpConfigFilename =
"tmp_MIDConfig.cfg";
68 encoder.
getWriter().writeConfFile(
"MID",
"RAWDATA", tmpConfigFilename.c_str(),
false);
70 for (
size_t itf = 0; itf < nTF; ++itf) {
71 for (
int ilocal = 0; ilocal < nDataInTF; ++ilocal) {
84 for (
size_t ilink = 0; ilink < nActiveLinks; ++ilink) {
85 auto& link = rawReader.
getLink(ilink);
90 std::vector<char> linkBuffer(tfsz);
91 link.readNextTF(linkBuffer.data());
92 buffer.insert(
buffer.end(), linkBuffer.begin(), linkBuffer.end());
95 fair::Logger::SetConsoleSeverity(
severity);
97 std::remove(
"MID.raw");
98 std::remove(tmpConfigFilename.c_str());
106static void BM_Decoder(benchmark::State&
state)
110 int nTF =
state.range(0);
111 int nEventPerTF =
state.range(1);
112 int nFiredPerEvent =
state.range(2);
117 for (
auto _ :
state) {
122 state.counters[
"num"] = benchmark::Counter(
num, benchmark::Counter::kIsRate);
125static void BM_LinkDecoder(benchmark::State&
state)
129 int nTF =
state.range(0);
130 int nEventPerTF =
state.range(1);
131 int nFiredPerEvent =
state.range(2);
135 std::vector<o2::mid::ROBoard>
data;
136 std::vector<o2::mid::ROFRecord> rofs;
138 for (
auto _ :
state) {
142 for (
auto it = parser.begin(),
end = parser.end(); it !=
end; ++it) {
143 if (it.size() == 0) {
146 auto* rdhPtr = it.template get_if<o2::header::RAWDataHeader>();
147 gsl::span<const uint8_t> payload(it.data(), it.size());
153 state.counters[
"num"] = benchmark::Counter(
num, benchmark::Counter::kIsRate);
156static void CustomArguments(benchmark::internal::Benchmark* bench)
159 bench->Args({1, 1, 1});
160 bench->Args({10, 1, 1});
162 bench->Args({1, 1, 70 * 4});
164 bench->Args({1, 100, 4});
167BENCHMARK(BM_LinkDecoder)->Apply(CustomArguments)->Unit(benchmark::kNanosecond);
168BENCHMARK(BM_Decoder)->Apply(CustomArguments)->Unit(benchmark::kNanosecond);
Strip pattern (aka digits)
Useful detector parameters for MID.
Class interface for the MID link decoder.
Generic parser for consecutive raw pages.
Reader for (multiple) raw data files.
std::vector< o2::mid::ColumnData > inputData
BENCHMARK(BM_LinkDecoder) -> Apply(CustomArguments) ->Unit(benchmark::kNanosecond)
std::vector< uint8_t > generateTestData(size_t nTF, size_t nDataInTF, size_t nColDataInEvent, size_t nLinks=o2::mid::crateparams::sNGBTs)
o2::mid::ColumnData getColData(uint8_t deId, uint8_t columnId, uint16_t nbp=0, uint16_t bp1=0, uint16_t bp2=0, uint16_t bp3=0, uint16_t bp4=0)
void process(gsl::span< const uint8_t > bytes)
void finalize(bool closeFile=true)
void init(std::string_view outDir=".", std::string_view fileFor="all", int verbosity=0, std::vector< ROBoardConfig > configurations=makeDefaultROBoardConfig())
void process(gsl::span< const ColumnData > data, InteractionRecord ir, EventType eventType=EventType::Standard)
void setNextTFToRead(uint32_t tf)
uint32_t getNTimeFrames() const
const LinkData & getLink(int i) const
std::unique_ptr< LinkDecoder > createLinkDecoder(const o2::header::RDHAny &rdh, uint16_t feeId, bool isDebugMode, uint8_t mask, const ElectronicsDelay &electronicsDelay, const FEEIdConfig &feeIdConfig)
Column data structure for MID.
uint8_t deId
Index of the detection element.
size_t getNextTFSize() const
o2::InteractionRecord ir(0, 0)