-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from gmbeard/feature/histogram-metrics
feat: Adds optional histogram metrics output
- Loading branch information
Showing
23 changed files
with
450 additions
and
405 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
Adds ability to output audio and video frame-time histogram metrics. This is enabled via the configure-time option `-DSHADOW_CAST_ENABLE_HISTOGRAMS=ON` |
This file contains 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 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 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 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 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 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,72 @@ | ||
#ifndef SHADOW_CAST_METRICS_FORMATTING_HPP_INCLUDED | ||
#define SHADOW_CAST_METRICS_FORMATTING_HPP_INCLUDED | ||
|
||
#include "metrics/histogram.hpp" | ||
#include <algorithm> | ||
#include <array> | ||
#include <cstddef> | ||
#include <iterator> | ||
#include <ostream> | ||
#include <string_view> | ||
|
||
namespace sc::metrics | ||
{ | ||
|
||
template <typename CharT, typename Traits, typename T, std::size_t N, T I> | ||
auto format_histogram_rows(std::basic_ostream<CharT, Traits>& os, | ||
Histogram<T, N, I> const& data, | ||
std::size_t column_size) -> void | ||
{ | ||
std::for_each( | ||
std::begin(data), std::end(data), [&](auto const& data_point) { | ||
os << "| "; | ||
os.width(column_size); | ||
os << std::get<0>(data_point); | ||
os << " | "; | ||
|
||
os.width(column_size); | ||
os << std::get<1>(data_point) << " |\n"; | ||
}); | ||
} | ||
|
||
template <typename CharT, typename Traits, typename T, std::size_t N, T I> | ||
auto format_histogram(std::basic_ostream<CharT, Traits>& os, | ||
Histogram<T, N, I> const& data, | ||
std::string_view series_name, | ||
std::string_view title = "") -> void | ||
{ | ||
if (title.size()) { | ||
os << title << '\n'; | ||
} | ||
|
||
constexpr std::size_t kColumnMargin = 1; | ||
auto const column_width = std::max(series_name.size(), 10ul); | ||
|
||
os << "| "; | ||
os.width(column_width); | ||
os << series_name << " | "; | ||
os.width(column_width); | ||
|
||
os << "Frequency" | ||
<< " |\n"; | ||
|
||
os.put('|').fill('-'); | ||
|
||
os.width(column_width + kColumnMargin * 2); | ||
os << '-' << '|'; | ||
os.width(column_width + kColumnMargin * 2); | ||
os << '-' << '|'; | ||
os.put('\n').fill(' '); | ||
|
||
format_histogram_rows(os, data, column_width); | ||
} | ||
|
||
template <typename CharT, typename Traits, typename T, std::size_t N, T I> | ||
auto format_histogram(std::basic_ostream<CharT, Traits>& os, | ||
Histogram<T, N, I> const& data) -> void | ||
{ | ||
format_histogram(os, data, "Buckets"); | ||
} | ||
} // namespace sc::metrics | ||
|
||
#endif // SHADOW_CAST_METRICS_FORMATTING_HPP_INCLUDED |
Oops, something went wrong.