summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Analytics.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2018-10-28 00:43:12 +0200
committerGitHub <noreply@github.com>2018-10-28 00:43:12 +0200
commit756a2fe14d87e47df8d08202117f7a84148eb235 (patch)
tree7eed93ec65d8cb9aedea609105cf5f15b96b499e /Source/Core/Common/Analytics.cpp
parentdd922660c9fdc466c707049888a24dfea0fb4c8c (diff)
parent83c3370c2a408b58f5ed1fe382f91ecddb812325 (diff)
Merge pull request #7517 from delroth/analytics-perf
Report performance information through our analytics subsystem
Diffstat (limited to 'Source/Core/Common/Analytics.cpp')
-rw-r--r--Source/Core/Common/Analytics.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/Source/Core/Common/Analytics.cpp b/Source/Core/Common/Analytics.cpp
index ab25cecabd..4441e9a7df 100644
--- a/Source/Core/Common/Analytics.cpp
+++ b/Source/Core/Common/Analytics.cpp
@@ -5,6 +5,7 @@
#include <cmath>
#include <cstdio>
#include <string>
+#include <type_traits>
#include "Common/Analytics.h"
#include "Common/CommonTypes.h"
@@ -17,7 +18,7 @@ namespace
{
// Format version number, used as the first byte of every report sent.
// Increment for any change to the wire format.
-constexpr u8 WIRE_FORMAT_VERSION = 0;
+constexpr u8 WIRE_FORMAT_VERSION = 1;
// Identifiers for the value types supported by the analytics reporting wire
// format.
@@ -28,8 +29,17 @@ enum class TypeId : u8
UINT = 2,
SINT = 3,
FLOAT = 4,
+
+ // Flags which can be combined with other types.
+ ARRAY = 0x80,
};
+TypeId operator|(TypeId l, TypeId r)
+{
+ using ut = std::underlying_type_t<TypeId>;
+ return static_cast<TypeId>(static_cast<ut>(l) | static_cast<ut>(r));
+}
+
void AppendBool(std::string* out, bool v)
{
out->push_back(v ? '\xFF' : '\x00');
@@ -112,6 +122,15 @@ void AnalyticsReportBuilder::AppendSerializedValue(std::string* report, float v)
AppendBytes(report, reinterpret_cast<u8*>(&v), sizeof(v), false);
}
+void AnalyticsReportBuilder::AppendSerializedValueVector(std::string* report,
+ const std::vector<u32>& v)
+{
+ AppendType(report, TypeId::UINT | TypeId::ARRAY);
+ AppendVarInt(report, v.size());
+ for (u32 x : v)
+ AppendVarInt(report, x);
+}
+
AnalyticsReporter::AnalyticsReporter()
{
m_reporter_thread = std::thread(&AnalyticsReporter::ThreadProc, this);