Skip to content

Commit

Permalink
🚸 better access to compute table stats
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Burgholzer <[email protected]>
  • Loading branch information
burgholzer committed Jul 27, 2023
1 parent 702413d commit a079ccf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion include/dd/ComputeTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ class ComputeTable {
}
}

[[nodiscard]] std::size_t getHits() const { return hits; }
[[nodiscard]] std::size_t getLookups() const { return lookups; }
[[nodiscard]] fp hitRatio() const {
return static_cast<fp>(hits) / static_cast<fp>(lookups);
if (lookups == 0U) {
return 1.;
}
return static_cast<fp>(getHits()) / static_cast<fp>(getLookups());
}

std::ostream& printStatistics(std::ostream& os = std::cout) {
Expand Down
7 changes: 6 additions & 1 deletion include/dd/UnaryComputeTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ class UnaryComputeTable {
lookups = 0;
}

[[nodiscard]] std::size_t getHits() const { return hits; }
[[nodiscard]] std::size_t getLookups() const { return lookups; }
[[nodiscard]] fp hitRatio() const {
return static_cast<fp>(hits) / static_cast<fp>(lookups);
if (lookups == 0U) {
return 1.;
}
return static_cast<fp>(getHits()) / static_cast<fp>(getLookups());
}

std::ostream& printStatistics(std::ostream& os = std::cout) {
Expand Down

0 comments on commit a079ccf

Please sign in to comment.