forked from GeneROOT/ramtools
-
Notifications
You must be signed in to change notification settings - Fork 8
Feat: support input sam files for conversion time benchmarks #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
neo-0007
wants to merge
1
commit into
compiler-research:develop
Choose a base branch
from
neo-0007:feat/conversion-benchmarking-ipfiles
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,18 @@ | |
| #include <filesystem> | ||
| #include <iostream> | ||
| #include <cstdio> | ||
| #include <vector> | ||
| #include <string> | ||
|
|
||
| #ifdef _WIN32 | ||
| #define NULL_DEVICE "NUL" | ||
| #else | ||
| #define NULL_DEVICE "/dev/null" | ||
| #endif | ||
|
|
||
| // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) | ||
| static std::vector<std::string> input_files; | ||
|
|
||
| static void BM_SamToTTree(benchmark::State &state) | ||
| { | ||
| int num_reads = state.range(0); | ||
|
|
@@ -72,8 +77,63 @@ static void BM_SamToRNTuple(benchmark::State &state) | |
| state.counters["reads_per_second"] = benchmark::Counter(num_reads, benchmark::Counter::kIsRate); | ||
| } | ||
|
|
||
| static void BM_SamToRNTupleRealData(benchmark::State &state) | ||
| { | ||
| auto file_index = static_cast<std::size_t>(state.range(0)); | ||
| std::string sam_file = input_files[file_index]; | ||
| std::string rntuple_file = sam_file + ".rntuple.root"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic] std::string rntuple_file = sam_file + ".rntuple.root";
^ |
||
|
|
||
| // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) | ||
| for (auto _ : state) { | ||
|
|
||
| FILE *original_stdout = stdout; | ||
| stdout = fopen(NULL_DEVICE, "w"); | ||
|
|
||
| samtoramntuple(sam_file.c_str(), rntuple_file.c_str(), | ||
| /*index=*/true, | ||
| /*split=*/true, | ||
| /*cache=*/true, | ||
| /*compression_algorithm=*/505, | ||
| /*quality_policy=*/0); | ||
|
|
||
| // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) | ||
| fclose(stdout); | ||
| stdout = original_stdout; | ||
|
|
||
| if (std::filesystem::exists(rntuple_file)) { | ||
| auto file_size = std::filesystem::file_size(rntuple_file); | ||
| double file_size_mb = static_cast<double>(file_size) / (1024.0 * 1024.0); | ||
|
|
||
| state.counters["file_size_mb"] = file_size_mb; | ||
| state.counters["MB_per_sec"] = benchmark::Counter(file_size_mb, benchmark::Counter::kIsRate); | ||
| } | ||
|
|
||
| std::remove(rntuple_file.c_str()); | ||
| } | ||
| } | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| if (argc > 1) { | ||
| std::cout << "Input Files Conversion Benchmark\n"; | ||
|
|
||
| for (int i = 1; i < argc; i++) { | ||
| // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) | ||
| input_files.emplace_back(argv[i]); | ||
| } | ||
|
|
||
| for (int i = 0; i < input_files.size(); i++) { | ||
| ::benchmark::RegisterBenchmark((input_files[i]), BM_SamToRNTupleRealData) | ||
| ->Args({i}) | ||
| ->Unit(benchmark::kMillisecond); | ||
| } | ||
|
|
||
| ::benchmark::Initialize(&argc, argv); | ||
| ::benchmark::RunSpecifiedBenchmarks(); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| std::cout << "Individual Conversion Time Benchmark" << std::endl; | ||
| std::cout << "====================================" << std::endl; | ||
| std::cout << "Measuring TTree and RNTuple conversion times separately" << std::endl; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: included header vector is not used directly [misc-include-cleaner]