Skip to content

Commit cae20bf

Browse files
committed
Suppress spammy telemetry if it's not an issue.
1 parent 1b98e91 commit cae20bf

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

SerialPrograms/Source/CommonFramework/Tools/StatAccumulator.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,30 @@ void StatAccumulatorI32::log(Logger& logger, const std::string& label, const cha
5757
PeriodicStatsReporterI32::PeriodicStatsReporterI32(
5858
const char* label,
5959
const char* units, double divider,
60-
std::chrono::milliseconds period
60+
std::chrono::milliseconds period,
61+
uint32_t min_report_time_threshold
6162
)
6263
: m_label(label)
6364
, m_units(units)
6465
, m_divider(divider)
6566
, m_period(period)
67+
, m_min_report_time_threshold(min_report_time_threshold)
6668
, m_last_report(current_time())
6769
{}
6870
void PeriodicStatsReporterI32::report_data(Logger& logger, uint32_t x){
6971
StatAccumulatorI32::operator+=(x);
7072
WallClock now = current_time();
71-
if (m_last_report + m_period <= now){
73+
if (m_last_report + m_period > now){
74+
return;
75+
}
76+
77+
if (this->max() >= m_min_report_time_threshold){
7278
log(logger, m_label, m_units, m_divider);
73-
clear();
74-
m_last_report = now;
7579
}
7680

81+
clear();
82+
m_last_report = now;
83+
7784
}
7885

7986

SerialPrograms/Source/CommonFramework/Tools/StatAccumulator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class PeriodicStatsReporterI32 : public StatAccumulatorI32{
4646
PeriodicStatsReporterI32(
4747
const char* label,
4848
const char* units, double divider,
49-
std::chrono::milliseconds period
49+
std::chrono::milliseconds period,
50+
uint32_t min_report_time_threshold = 0
5051
);
5152
void report_data(Logger& logger, uint32_t x);
5253

@@ -55,6 +56,7 @@ class PeriodicStatsReporterI32 : public StatAccumulatorI32{
5556
const char* m_units;
5657
double m_divider;
5758
std::chrono::milliseconds m_period;
59+
uint32_t m_min_report_time_threshold;
5860
WallClock m_last_report;
5961
};
6062

SerialPrograms/Source/CommonFramework/VideoPipeline/UI/VideoOverlayWidget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ VideoOverlayWidget::VideoOverlayWidget(QWidget& parent, VideoOverlaySession& ses
3636
, m_images(std::make_shared<std::vector<OverlayImage>>(session.images()))
3737
, m_log(std::make_shared<std::vector<OverlayLogLine>>(session.log_texts()))
3838
// , m_stats(nullptr)
39-
, m_stats_paint("VideoOverlayWidget::paintEvent", "ms", 1000, std::chrono::seconds(10))
39+
, m_stats_paint(
40+
"VideoOverlayWidget::paintEvent",
41+
"ms", 1000,
42+
std::chrono::seconds(10), 2000
43+
)
4044
{
4145
setAttribute(Qt::WA_NoSystemBackground);
4246
setAttribute(Qt::WA_TranslucentBackground);

SerialPrograms/Source/CommonFramework/VideoPipeline/VideoSource.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ namespace PokemonAutomation{
1313
VideoSource::VideoSource(Logger& m_logger, bool allow_watchdog_reset)
1414
: m_logger(m_logger)
1515
, m_allow_watchdog_reset(allow_watchdog_reset)
16-
, m_stats_report_source_frame("VideoSource::report_source_frame()", "ms", 1000, std::chrono::seconds(60))
17-
, m_stats_report_rendered_frame("VideoSource::report_rendered_frame()", "ms", 1000, std::chrono::seconds(60))
16+
, m_stats_report_source_frame(
17+
"VideoSource::report_source_frame()",
18+
"ms", 1000,
19+
std::chrono::seconds(60), 1000
20+
)
21+
, m_stats_report_rendered_frame(
22+
"VideoSource::report_rendered_frame()",
23+
"ms", 1000,
24+
std::chrono::seconds(60), 1000
25+
)
1826
, m_sanitizer("VideoSource")
1927
{}
2028

0 commit comments

Comments
 (0)