Repository navigation
Improve dtest -r per-deal timing report #305
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a00eaf9
Add column headings to dtest -r per-board timing report.
tameware e56c475
Report every input deal from dtest -r across solve batches.
tameware 3a95bf8
Show dtest -r times as ms with one decimal place.
tameware 499ab62
Right-align dtest -r ms and board columns with spaces.
tameware 679846d
Tighten blank lines around the dtest -r report title.
tameware 6f05513
Restore ostream formatting after dtest -r report and avoid a copy.
tameware 2addd77
Use explicit << between adjacent -r usage string literals.
tameware 1f0d4eb
Reserve board_times capacity when dtest -r is enabled.
tameware a1bddbb
Put standard headers before project headers in loop.hpp.
tameware 33736a7
Group standard includes before project includes in loop.cpp.
tameware 9f91431
Saturate board times into int and align report helper indentation.
tameware 245d0ae
Restore utilities_log_snapshot_test target accidentally dropped.
tameware 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
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /// @file report_board_timings.cpp | ||
| /// @brief Format dtest `-r` / `--report` per-board timing output. | ||
|
|
||
| #include "report_board_timings.hpp" | ||
|
|
||
| #include <algorithm> | ||
| #include <cstdlib> | ||
| #include <iomanip> | ||
| #include <sstream> | ||
|
|
||
| namespace | ||
| { | ||
|
|
||
| int decimal_digits(int value) | ||
| { | ||
| const int n = std::abs(value); | ||
| int digits = 1; | ||
| int x = n; | ||
| while (x >= 10) | ||
| { | ||
| x /= 10; | ||
| ++digits; | ||
| } | ||
| if (value < 0) | ||
| ++digits; | ||
| return digits; | ||
| } | ||
|
|
||
| int board_column_width(const std::vector<std::pair<int, int>>& times) | ||
| { | ||
| constexpr int kHeaderWidth = 5; // "board" | ||
| int width = kHeaderWidth; | ||
| for (const auto& p : times) | ||
| width = std::max(width, decimal_digits(p.first)); | ||
| return width; | ||
| } | ||
|
|
||
| int ms_column_width(const std::vector<std::pair<int, int>>& times) | ||
| { | ||
| constexpr int kHeaderWidth = 2; // "ms" | ||
| int width = kHeaderWidth; | ||
| for (const auto& p : times) | ||
| { | ||
| std::ostringstream formatted; | ||
| formatted << std::fixed << std::setprecision(1) | ||
| << (static_cast<double>(p.second) / 1000.0); | ||
| width = std::max(width, static_cast<int>(formatted.str().size())); | ||
| } | ||
| return width; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| void print_per_board_timings( | ||
| std::ostream& out, | ||
| std::vector<std::pair<int, int>> times) | ||
| { | ||
| std::sort(times.begin(), times.end(), [](const auto& a, const auto& b) { | ||
| return a.second > b.second; | ||
| }); | ||
|
|
||
| const int ms_width = ms_column_width(times); | ||
| const int board_width = board_column_width(times); | ||
|
|
||
| // Preserve caller formatting; setw is one-shot but fixed/precision/align persist. | ||
| const auto saved_flags = out.flags(); | ||
| const auto saved_precision = out.precision(); | ||
|
|
||
| out << "\nPer-board timings (ms) sorted by longest first:\n\n"; | ||
| out << std::right << std::setw(ms_width) << "ms" << " " | ||
| << std::setw(board_width) << "board" << "\n"; | ||
| out << std::fixed << std::setprecision(1); | ||
| for (const auto& p : times) | ||
| { | ||
| out << std::right << std::setw(ms_width) | ||
| << (static_cast<double>(p.second) / 1000.0) << " " | ||
| << std::setw(board_width) << p.first << "\n"; | ||
| } | ||
|
|
||
| out.flags(saved_flags); | ||
| out.precision(saved_precision); | ||
| } | ||
|
|
||
| void append_batch_board_times( | ||
| std::vector<std::pair<int, int>>& accumulated, | ||
| const std::vector<std::pair<int, int>>& batch_times, | ||
| int file_offset) | ||
| { | ||
| accumulated.reserve(accumulated.size() + batch_times.size()); | ||
| for (const auto& p : batch_times) | ||
| accumulated.emplace_back(p.first + file_offset, p.second); | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /// @file report_board_timings.hpp | ||
| /// @brief Format dtest `-r` / `--report` per-board timing output. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <ostream> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| /// Print per-board timings sorted by longest first. | ||
| /// | ||
| /// Each element of @p times is `(board_index, time_us)`, where `board_index` | ||
| /// is the 0-based deal index in the input file and `time_us` is wall time in | ||
| /// microseconds. Printed times are milliseconds with one decimal place. | ||
| /// Both the `ms` and `board` columns are right-aligned with spaces (no tabs). | ||
| /// Output includes a title line, a heading line, then one row per board. | ||
| void print_per_board_timings( | ||
| std::ostream& out, | ||
| std::vector<std::pair<int, int>> times); | ||
|
|
||
| /// Append one solve-batch's scheduler timings into a file-wide report. | ||
| /// | ||
| /// @p batch_times entries use batch-local indices `(0 .. batch_size-1)`. | ||
| /// Each is remapped to `board_index + file_offset` so multi-batch runs | ||
| /// (chunks of `MAXNOOFBOARDS`) report every deal in the input file. | ||
| void append_batch_board_times( | ||
| std::vector<std::pair<int, int>>& accumulated, | ||
| const std::vector<std::pair<int, int>>& batch_times, | ||
| int file_offset); |
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.
Uh oh!
There was an error while loading. Please reload this page.