Core/Analytics: add support for performance sampling
Samples are pushed to the analytics module every frame but only sent once every ~15min. We send data for 100 frames at a time.
This commit is contained in:
1 parent
d98c0da41b
commit
6a891ea37c
2 files changed
+97
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
@@ -20,6 +21,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Random.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Timer.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
@@ -128,6 +130,71 @@ void DolphinAnalytics::ReportGameStart()
|
||||
Common::AnalyticsReportBuilder builder(m_per_game_builder);
|
||||
builder.AddData("type", "game-start");
|
||||
Send(builder);
|
||||
|
||||
InitializePerformanceSampling();
|
||||
}
|
||||
|
||||
void DolphinAnalytics::ReportPerformanceInfo(PerformanceSample&& sample)
|
||||
{
|
||||
if (ShouldStartPerformanceSampling())
|
||||
{
|
||||
m_sampling_performance_info = true;
|
||||
}
|
||||
|
||||
if (m_sampling_performance_info)
|
||||
{
|
||||
m_performance_samples.emplace_back(std::move(sample));
|
||||
}
|
||||
|
||||
if (m_performance_samples.size() >= NUM_PERFORMANCE_SAMPLES_PER_REPORT)
|
||||
{
|
||||
std::vector<u32> speed_times_1000(m_performance_samples.size());
|
||||
std::vector<u32> num_prims(m_performance_samples.size());
|
||||
std::vector<u32> num_draw_calls(m_performance_samples.size());
|
||||
for (size_t i = 0; i < m_performance_samples.size(); ++i)
|
||||
{
|
||||
speed_times_1000[i] = static_cast<u32>(m_performance_samples[i].speed_ratio * 1000);
|
||||
num_prims[i] = m_performance_samples[i].num_prims;
|
||||
num_draw_calls[i] = m_performance_samples[i].num_draw_calls;
|
||||
}
|
||||
|
||||
// The per game builder should already exist -- there is no way we can be reporting performance
|
||||
// info without a game start event having been generated.
|
||||
Common::AnalyticsReportBuilder builder(m_per_game_builder);
|
||||
builder.AddData("type", "performance");
|
||||
builder.AddData("speed", speed_times_1000);
|
||||
builder.AddData("prims", num_prims);
|
||||
builder.AddData("draw-calls", num_draw_calls);
|
||||
|
||||
Send(builder);
|
||||
|
||||
// Clear up and stop sampling until next time ShouldStartPerformanceSampling() says so.
|
||||
m_performance_samples.clear();
|
||||
m_sampling_performance_info = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinAnalytics::InitializePerformanceSampling()
|
||||
{
|
||||
m_performance_samples.clear();
|
||||
m_sampling_performance_info = false;
|
||||
|
||||
u64 wait_us =
|
||||
PERFORMANCE_SAMPLING_INITIAL_WAIT_TIME_SECS * 1000000 +
|
||||
Common::Random::GenerateValue<u64>() % (PERFORMANCE_SAMPLING_WAIT_TIME_JITTER_SECS * 1000000);
|
||||
m_sampling_next_start_us = Common::Timer::GetTimeUs() + wait_us;
|
||||
}
|
||||
|
||||
bool DolphinAnalytics::ShouldStartPerformanceSampling()
|
||||
{
|
||||
if (Common::Timer::GetTimeUs() < m_sampling_next_start_us)
|
||||
return false;
|
||||
|
||||
u64 wait_us =
|
||||
PERFORMANCE_SAMPLING_INTERVAL_SECS * 1000000 +
|
||||
Common::Random::GenerateValue<u64>() % (PERFORMANCE_SAMPLING_WAIT_TIME_JITTER_SECS * 1000000);
|
||||
m_sampling_next_start_us = Common::Timer::GetTimeUs() + wait_us;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DolphinAnalytics::MakeBaseBuilder()
|
||||
|
||||
Reference in new issue
Block a user