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
15using namespace o2::framework;
16
18{
19 public:
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 {
27 };
28 static_assert(sizeof(RawPage) == PageSize);
29
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
57
58static 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
75static void BM_RawParserV4(benchmark::State& state)
76{
77 size_t nofPages = state.range(0);
78 if (nofPages > TestPages::MaxNPages) {
79 return;
80 }
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
92BENCHMARK(BM_RawParserV4)->Arg(1)->Arg(8)->Arg(256)->Arg(1024)->Arg(16 * 1024)->Arg(256 * 1024);
93BENCHMARK(BM_RawParserAuto)->Arg(1)->Arg(8)->Arg(256)->Arg(1024)->Arg(16 * 1024)->Arg(256 * 1024);
94
benchmark::State & state
Generic parser for consecutive raw pages.
BENCHMARK_MAIN()
TestPages gPages
BENCHMARK(BM_RawParserV4) -> Arg(1) ->Arg(8) ->Arg(256) ->Arg(1024) ->Arg(16 *1024) ->Arg(256 *1024)
static constexpr size_t PageDataSize
const char * data() const
static constexpr size_t MaxNPages
size_t size() const
static constexpr size_t PageSize
o2::header::RAWDataHeaderV4 V4
GLint GLsizei count
Definition glcorearb.h:399
GLboolean * data
Definition glcorearb.h:298
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20