Project
Loading...
Searching...
No Matches
benchmark_RawParser.cxx
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
#include <benchmark/benchmark.h>
12
13
#include "
DPLUtils/RawParser.h
"
14
15
using namespace
o2::framework
;
16
17
class
TestPages
18
{
19
public
:
20
using
V4
=
o2::header::RAWDataHeaderV4
;
21
static
constexpr
size_t
MaxNPages
= 256 * 1024;
22
static
constexpr
size_t
PageSize
= 8192;
23
static
constexpr
size_t
PageDataSize
=
PageSize
-
sizeof
(
V4
);
24
struct
RawPage
{
25
V4
rdh
;
26
char
data
[
PageDataSize
];
27
};
28
static_assert
(
sizeof
(
RawPage
) ==
PageSize
);
29
30
TestPages
()
31
: mPages(
MaxNPages
)
32
{
33
for
(
int
pageNo = 0; pageNo < mPages.size(); pageNo++) {
34
mPages[pageNo].rdh.version = 4;
35
mPages[pageNo].rdh.headerSize =
sizeof
(
V4
);
36
mPages[pageNo].rdh.offsetToNext =
PageSize
;
37
auto
*
data
=
reinterpret_cast<
size_t
*
>
(&mPages[pageNo].data);
38
*
data
= pageNo;
39
}
40
}
41
42
const
char
*
data
()
const
43
{
44
return
reinterpret_cast<
const
char
*
>
(mPages.data());
45
}
46
47
size_t
size
()
const
48
{
49
return
mPages.size() *
sizeof
(
decltype
(mPages)::value_type);
50
}
51
52
private
:
53
std::vector<RawPage> mPages;
54
};
55
56
TestPages
gPages
;
57
58
static
void
BM_RawParserAuto(benchmark::State& state)
59
{
60
size_t
nofPages =
state
.range(0);
61
if
(nofPages >
TestPages::MaxNPages
) {
62
return
;
63
}
64
using
Parser =
RawParser<TestPages::PageSize>
;
65
Parser parser(
reinterpret_cast<
const
char
*
>
(
gPages
.
data
()), nofPages *
TestPages::PageSize
);
66
size_t
count
= 0;
67
auto
processor = [&
count
](
auto
data
,
size_t
length
) {
68
count
++;
69
};
70
for
(
auto
_ :
state
) {
71
parser.parse(processor);
72
}
73
}
74
75
static
void
BM_RawParserV4(benchmark::State& state)
76
{
77
size_t
nofPages =
state
.range(0);
78
if
(nofPages >
TestPages::MaxNPages
) {
79
return
;
80
}
81
using
Parser =
raw_parser::ConcreteRawParser<TestPages::V4, TestPages::PageSize, true>
;
82
Parser parser(
reinterpret_cast<
const
char
*
>
(
gPages
.
data
()), nofPages *
TestPages::PageSize
);
83
size_t
count
= 0;
84
auto
processor = [&
count
](
auto
data
,
size_t
length
) {
85
count
++;
86
};
87
for
(
auto
_ :
state
) {
88
parser.parse(processor);
89
}
90
}
91
92
BENCHMARK
(BM_RawParserV4)->Arg(1)->Arg(8)->Arg(256)->Arg(1024)->Arg(16 * 1024)->Arg(256 * 1024);
93
BENCHMARK
(BM_RawParserAuto)->Arg(1)->Arg(8)->Arg(256)->Arg(1024)->Arg(16 * 1024)->Arg(256 * 1024);
94
95
BENCHMARK_MAIN
();
state
benchmark::State & state
Definition
BenchCathodeSegmentation.cxx:58
RawParser.h
Generic parser for consecutive raw pages.
BENCHMARK_MAIN
BENCHMARK_MAIN()
gPages
TestPages gPages
Definition
benchmark_RawParser.cxx:56
BENCHMARK
BENCHMARK(BM_RawParserV4) -> Arg(1) ->Arg(8) ->Arg(256) ->Arg(1024) ->Arg(16 *1024) ->Arg(256 *1024)
TestPages
Definition
benchmark_RawParser.cxx:18
TestPages::PageDataSize
static constexpr size_t PageDataSize
Definition
benchmark_RawParser.cxx:23
TestPages::data
const char * data() const
Definition
benchmark_RawParser.cxx:42
TestPages::MaxNPages
static constexpr size_t MaxNPages
Definition
benchmark_RawParser.cxx:21
TestPages::TestPages
TestPages()
Definition
benchmark_RawParser.cxx:30
TestPages::size
size_t size() const
Definition
benchmark_RawParser.cxx:47
TestPages::PageSize
static constexpr size_t PageSize
Definition
benchmark_RawParser.cxx:22
TestPages::V4
o2::header::RAWDataHeaderV4 V4
Definition
benchmark_RawParser.cxx:20
o2::framework::RawParser
Definition
RawParser.h:466
o2::framework::raw_parser::ConcreteRawParser
Definition
RawParser.h:109
count
GLint GLsizei count
Definition
glcorearb.h:399
data
GLboolean * data
Definition
glcorearb.h:298
length
GLuint GLsizei GLsizei * length
Definition
glcorearb.h:790
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
TFIDInfo.h:20
TestPages::RawPage
Definition
benchmark_RawParser.cxx:24
TestPages::RawPage::rdh
V4 rdh
Definition
benchmark_RawParser.cxx:25
o2::header::RAWDataHeaderV4
Definition
RAWDataHeader.h:382
Framework
Utils
test
benchmark_RawParser.cxx
Generated on Tue Feb 25 2025 23:16:42 for Project by
1.9.8