Skip to content

Commit 9ccb15f

Browse files
committed
Bk bench (#1827)
* Add a small binary to benchmark bookkeeping * format * blabla * add a possible delay between calls * format
1 parent cb2381f commit 9ccb15f

2 files changed

Lines changed: 99 additions & 3 deletions

File tree

Framework/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ set(EXE_SRCS
155155
src/runMergerCalculator.cxx
156156
src/runUploadRootObjects.cxx
157157
src/runFileMerger.cxx
158-
src/runMetadataUpdater.cxx)
158+
src/runMetadataUpdater.cxx
159+
src/runBookkeepingBenchmark.cxx)
159160

160161
set(EXE_NAMES
161162
o2-qc-run-producer
@@ -172,7 +173,8 @@ set(EXE_NAMES
172173
o2-qc-merger-calculator
173174
o2-qc-upload-root-objects
174175
o2-qc-file-merger
175-
o2-qc-metadata-updater)
176+
o2-qc-metadata-updater
177+
o2-qc-bk-benchmark)
176178

177179
# These were the original names before the convention changed. We will get rid
178180
# of them but for the time being we want to create symlinks to avoid confusion.
@@ -192,7 +194,9 @@ set(EXE_OLD_NAMES
192194
o2-qc-merger-calculator
193195
o2-qc-upload-root-objects
194196
o2-qc-file-merger
195-
o2-qc-metadata-updater)
197+
o2-qc-metadata-updater
198+
o2-qc-bk-benchmark)
199+
196200

197201
# As per https://stackoverflow.com/questions/35765106/symbolic-links-cmake
198202
macro(install_symlink filepath sympath)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
12+
#include "QualityControl/Bookkeeping.h"
13+
#include <iostream>
14+
#include <boost/program_options.hpp>
15+
#include "BookkeepingApi/BkpProtoClientFactory.h"
16+
#include "QualityControl/Activity.h"
17+
#include <Common/Timer.h>
18+
#include "QualityControl/QcInfoLogger.h"
19+
20+
using namespace std;
21+
namespace bpo = boost::program_options;
22+
using namespace o2::bkp::api;
23+
using namespace o2::bkp::api::proto;
24+
using namespace o2::quality_control::core;
25+
26+
/**
27+
* A small utility to stress test the bookkeeping api.
28+
*/
29+
30+
int main(int argc, const char* argv[])
31+
{
32+
bpo::options_description desc{ "Options" };
33+
desc.add_options()("help,h", "Help screen")("url,u", bpo::value<std::string>()->required(), "URL to the Bookkeeping")("run,r", bpo::value<int>())("max,m", bpo::value<int>()->default_value(10000), "Max number of executions, default: 10000")("printCycles,p", bpo::value<int>()->default_value(1000), "We print every X cycles, default: 1000")("printActivity", bpo::value<bool>()->default_value(false), "just to check that we get something in the activity.")("delay,d", bpo::value<int>()->default_value(0), "Minimum delay between calls in ms, default 0");
34+
35+
bpo::variables_map vm;
36+
store(parse_command_line(argc, argv, desc), vm);
37+
38+
if (vm.count("help")) {
39+
std::cout << desc << std::endl;
40+
return 0;
41+
}
42+
notify(vm);
43+
44+
const auto url = vm["url"].as<string>();
45+
cout << "url : " << url << endl;
46+
const auto run = vm["run"].as<int>();
47+
cout << "run : " << run << endl;
48+
const auto max = vm["max"].as<int>();
49+
cout << "max : " << max << endl;
50+
const auto printCycles = vm["printCycles"].as<int>();
51+
cout << "printCycles : " << printCycles << endl;
52+
const auto printActivity = vm["printActivity"].as<bool>();
53+
cout << "printActivity : " << printActivity << endl;
54+
const auto minDelay = vm["delay"].as<int>();
55+
cout << "minDelay : " << minDelay << endl;
56+
57+
ILOG_INST.filterDiscardDebug(true);
58+
ILOG_INST.filterDiscardLevel(11);
59+
60+
Bookkeeping::getInstance().init(url);
61+
62+
AliceO2::Common::Timer timer;
63+
AliceO2::Common::Timer triggerTimer;
64+
triggerTimer.reset();
65+
Activity activity;
66+
double totalDuration = 0;
67+
double cycleDuration = 0;
68+
int numberOfExecutionsInCycle = 0;
69+
int totalNumberOfExecutions = 0;
70+
71+
while (totalNumberOfExecutions < max) {
72+
if (triggerTimer.isTimeout()) {
73+
numberOfExecutionsInCycle++;
74+
totalNumberOfExecutions++;
75+
triggerTimer.reset(minDelay * 1000);
76+
timer.reset();
77+
Bookkeeping::getInstance().populateActivity(activity, run);
78+
auto duration = timer.getTime();
79+
if (printActivity) {
80+
cout << activity << endl;
81+
}
82+
totalDuration += duration;
83+
cycleDuration += duration;
84+
if (totalNumberOfExecutions % printCycles == 0) {
85+
cout << "average duration last " << printCycles << " calls in [ms]: " << cycleDuration / numberOfExecutionsInCycle * 1000 << endl;
86+
numberOfExecutionsInCycle = 0;
87+
cycleDuration = 0;
88+
}
89+
}
90+
}
91+
cout << "average duration overall in ms : " << totalDuration / totalNumberOfExecutions * 1000 << endl;
92+
}

0 commit comments

Comments
 (0)