|
6 | 6 | #include "rootbench/RBConfig.h" |
7 | 7 |
|
8 | 8 |
|
9 | | -static void BM_TFile_RDFSnapshot_ZLIB(benchmark::State &state) { |
10 | | - ROOT::EnableImplicitMT(); |
11 | | - ROOT::RDF::RSnapshotOptions options; |
12 | | - options.fCompressionAlgorithm = ROOT::ECompressionAlgorithm::kZLIB; |
13 | | - |
| 9 | +auto SetupRDF() { |
14 | 10 | // We create an empty data frame |
15 | 11 | ROOT::RDataFrame tdf(100000); |
16 | 12 | // We now fill it with random numbers |
17 | 13 | gRandom->SetSeed(1); |
18 | 14 | auto tdf_1 = tdf.Define("rnd", []() { return gRandom->Gaus(); }); |
| 15 | + return tdf_1; |
| 16 | +} |
19 | 17 |
|
20 | | - for (auto _ : state) { |
21 | | - //And we write out the dataset on disk |
22 | | - tdf_1.Snapshot("randomNumbers", "bench_data.root", "", options); |
23 | | - } |
| 18 | +auto SetupRDFOptions(ROOT::ECompressionAlgorithm alg, int level) { |
| 19 | + ROOT::RDF::RSnapshotOptions options; |
| 20 | + options.fCompressionAlgorithm = alg; |
| 21 | + options.fCompressionLevel = level; |
| 22 | + return options; |
24 | 23 | } |
25 | | -BENCHMARK(BM_TFile_RDFSnapshot_ZLIB)->Unit(benchmark::kMicrosecond); |
26 | 24 |
|
27 | 25 |
|
28 | | -static void BM_TFile_RDFSnapshot_LZ4(benchmark::State &state) { |
29 | | - ROOT::EnableImplicitMT(); |
30 | | - ROOT::RDF::RSnapshotOptions options; |
31 | | - options.fCompressionAlgorithm = ROOT::ECompressionAlgorithm::kLZ4; |
| 26 | +static void BM_TFile_RDFSnapshot_ZLIB(benchmark::State &state) { |
| 27 | + auto tdf = SetupRDF(); |
| 28 | + auto options = SetupRDFOptions(ROOT::ECompressionAlgorithm::kZLIB, 1); |
| 29 | + for (auto _ : state) { |
| 30 | + //And we write out the dataset on disk |
| 31 | + tdf.Snapshot("randomNumbers", "bench_data.root", {"rnd"}, options); |
| 32 | + } |
| 33 | +} |
| 34 | +BENCHMARK(BM_TFile_RDFSnapshot_ZLIB)->Unit(benchmark::kMicrosecond); |
32 | 35 |
|
33 | | - // We create an empty data frame |
34 | | - ROOT::RDataFrame tdf(100000); |
35 | | - // We now fill it with random numbers |
36 | | - gRandom->SetSeed(1); |
37 | | - auto tdf_1 = tdf.Define("rnd", []() { return gRandom->Gaus(); }); |
38 | 36 |
|
39 | | - for (auto _ : state) { |
40 | | - //And we write out the dataset on disk |
41 | | - tdf_1.Snapshot("randomNumbers", "bench_data.root", "", options); |
42 | | - } |
| 37 | +static void BM_TFile_RDFSnapshot_LZ4(benchmark::State &state) { |
| 38 | + auto tdf = SetupRDF(); |
| 39 | + auto options = SetupRDFOptions(ROOT::ECompressionAlgorithm::kLZ4, 4); |
| 40 | + for (auto _ : state) { |
| 41 | + //And we write out the dataset on disk |
| 42 | + tdf.Snapshot("randomNumbers", "bench_data.root", {"rnd"}, options); |
| 43 | + } |
43 | 44 | } |
44 | 45 | BENCHMARK(BM_TFile_RDFSnapshot_LZ4)->Unit(benchmark::kMicrosecond); |
45 | 46 |
|
46 | 47 |
|
47 | 48 | static void BM_TFile_RDFSnapshot_LZMA (benchmark::State &state) { |
48 | | - ROOT::EnableImplicitMT(); |
49 | | - ROOT::RDF::RSnapshotOptions options; |
50 | | - options.fCompressionAlgorithm = ROOT::ECompressionAlgorithm::kLZMA; |
51 | | - |
52 | | - // We create an empty data frame |
53 | | - ROOT::RDataFrame tdf(100000); |
54 | | - // We now fill it with random numbers |
55 | | - gRandom->SetSeed(1); |
56 | | - auto tdf_1 = tdf.Define("rnd", []() { return gRandom->Gaus(); }); |
57 | | - |
58 | | - for (auto _ : state) { |
59 | | - //And we write out the dataset on disk |
60 | | - tdf_1.Snapshot("randomNumbers", "bench_data.root", "", options); |
61 | | - } |
| 49 | + auto tdf = SetupRDF(); |
| 50 | + auto options = SetupRDFOptions(ROOT::ECompressionAlgorithm::kLZMA, 8); |
| 51 | + for (auto _ : state) { |
| 52 | + //And we write out the dataset on disk |
| 53 | + tdf.Snapshot("randomNumbers", "bench_data.root", {"rnd"}, options); |
| 54 | + } |
62 | 55 | } |
63 | 56 | BENCHMARK(BM_TFile_RDFSnapshot_LZMA)->Unit(benchmark::kMicrosecond); |
64 | 57 |
|
65 | 58 | static void BM_TFile_RDFSnapshot_ZSTD (benchmark::State &state) { |
66 | | - ROOT::EnableImplicitMT(); |
67 | | - ROOT::RDF::RSnapshotOptions options; |
68 | | - options.fCompressionAlgorithm = ROOT::ECompressionAlgorithm::kZSTD; |
69 | | - |
70 | | - // We create an empty data frame |
71 | | - ROOT::RDataFrame tdf(100000); |
72 | | - // We now fill it with random numbers |
73 | | - gRandom->SetSeed(1); |
74 | | - auto tdf_1 = tdf.Define("rnd", []() { return gRandom->Gaus(); }); |
75 | | - |
76 | | - for (auto _ : state) { |
77 | | - //And we write out the dataset on disk |
78 | | - tdf_1.Snapshot("randomNumbers", "bench_data.root", "", options); |
79 | | - } |
| 59 | + auto tdf = SetupRDF(); |
| 60 | + auto options = SetupRDFOptions(ROOT::ECompressionAlgorithm::kZSTD, 6); |
| 61 | + for (auto _ : state) { |
| 62 | + //And we write out the dataset on disk |
| 63 | + tdf.Snapshot("randomNumbers", "bench_data.root", {"rnd"}, options); |
| 64 | + } |
80 | 65 | } |
81 | 66 | BENCHMARK(BM_TFile_RDFSnapshot_ZSTD)->Unit(benchmark::kMicrosecond); |
82 | 67 |
|
|
0 commit comments