forked from ad-freiburg/qlever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParallelMergeBenchmark.cpp
55 lines (47 loc) · 1.51 KB
/
ParallelMergeBenchmark.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Created by kalmbacj on 9/8/23.
//
#include <cmath>
#include "../benchmark/infrastructure/Benchmark.h"
#include "../test/util/IdTableHelpers.h"
#include "util/Log.h"
#include "util/ParallelMultiwayMerge.h"
namespace ad_benchmark {
class IdTableCompressedWriterBenchmark : public BenchmarkInterface {
std::string name() const final {
return "Benchmarks for parallel multiway merging";
}
BenchmarkResults runAllBenchmarks() final {
constexpr size_t numInputs = 20000;
constexpr size_t numInputRows = 50'000;
BenchmarkResults results{};
auto generateRandomVec =
[gen = ad_utility::FastRandomIntGenerator<uint64_t>{}]() mutable {
std::vector<size_t> res;
for ([[maybe_unused]] auto i :
ad_utility::integerRange(numInputRows)) {
res.push_back(gen());
}
std::ranges::sort(res);
return res;
};
std::vector<std::vector<size_t>> inputs;
inputs.resize(numInputs);
std::ranges::generate(inputs, generateRandomVec);
auto run = [&inputs]() {
auto merger = ad_utility::parallelMultiwayMerge<size_t, false>(
4_GB, inputs, std::less<>{});
size_t result{};
for (const auto& i : merger) {
for (auto el : i) {
result += el;
}
}
LOG(INFO) << "result was " << result << std::endl;
};
results.addMeasurement("simple merge", run);
return results;
}
};
AD_REGISTER_BENCHMARK(IdTableCompressedWriterBenchmark);
} // namespace ad_benchmark