summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2017-05-02 00:09:15 -0400
committerGravatar bunnei2017-05-24 19:16:22 -0400
commitf3e14cae1e644b7e072796f2c26eab67b7a5d1b7 (patch)
tree27a0b689d399425f54e1559c64a8cf935ce81c5e /src
parentcommon: Add a generic interface for logging telemetry fields. (diff)
downloadyuzu-f3e14cae1e644b7e072796f2c26eab67b7a5d1b7.tar.gz
yuzu-f3e14cae1e644b7e072796f2c26eab67b7a5d1b7.tar.xz
yuzu-f3e14cae1e644b7e072796f2c26eab67b7a5d1b7.zip
core: Keep track of telemetry for the current emulation session.
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/core.cpp3
-rw-r--r--src/core/core.h16
-rw-r--r--src/core/telemetry_session.cpp24
-rw-r--r--src/core/telemetry_session.h38
5 files changed, 83 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c733e5d21..57504529f 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -174,6 +174,7 @@ set(SRCS
174 memory.cpp 174 memory.cpp
175 perf_stats.cpp 175 perf_stats.cpp
176 settings.cpp 176 settings.cpp
177 telemetry_session.cpp
177 ) 178 )
178 179
179set(HEADERS 180set(HEADERS
@@ -366,6 +367,7 @@ set(HEADERS
366 mmio.h 367 mmio.h
367 perf_stats.h 368 perf_stats.h
368 settings.h 369 settings.h
370 telemetry_session.h
369 ) 371 )
370 372
371include_directories(../../externals/dynarmic/include) 373include_directories(../../externals/dynarmic/include)
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 881f1e93c..450e7566d 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -132,6 +132,8 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
132 cpu_core = std::make_unique<ARM_DynCom>(USER32MODE); 132 cpu_core = std::make_unique<ARM_DynCom>(USER32MODE);
133 } 133 }
134 134
135 telemetry_session = std::make_unique<Core::TelemetrySession>();
136
135 CoreTiming::Init(); 137 CoreTiming::Init();
136 HW::Init(); 138 HW::Init();
137 Kernel::Init(system_mode); 139 Kernel::Init(system_mode);
@@ -162,6 +164,7 @@ void System::Shutdown() {
162 CoreTiming::Shutdown(); 164 CoreTiming::Shutdown();
163 cpu_core = nullptr; 165 cpu_core = nullptr;
164 app_loader = nullptr; 166 app_loader = nullptr;
167 telemetry_session = nullptr;
165 168
166 LOG_DEBUG(Core, "Shutdown OK"); 169 LOG_DEBUG(Core, "Shutdown OK");
167} 170}
diff --git a/src/core/core.h b/src/core/core.h
index 6c9c936b5..6af772831 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -9,6 +9,7 @@
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/memory.h" 10#include "core/memory.h"
11#include "core/perf_stats.h" 11#include "core/perf_stats.h"
12#include "core/telemetry_session.h"
12 13
13class EmuWindow; 14class EmuWindow;
14class ARM_Interface; 15class ARM_Interface;
@@ -80,6 +81,14 @@ public:
80 return cpu_core != nullptr; 81 return cpu_core != nullptr;
81 } 82 }
82 83
84 /**
85 * Returns a reference to the telemetry session for this emulation session.
86 * @returns Reference to the telemetry session.
87 */
88 Core::TelemetrySession& TelemetrySession() const {
89 return *telemetry_session;
90 }
91
83 /// Prepare the core emulation for a reschedule 92 /// Prepare the core emulation for a reschedule
84 void PrepareReschedule(); 93 void PrepareReschedule();
85 94
@@ -117,6 +126,9 @@ private:
117 /// When true, signals that a reschedule should happen 126 /// When true, signals that a reschedule should happen
118 bool reschedule_pending{}; 127 bool reschedule_pending{};
119 128
129 /// Telemetry session for this emulation session
130 std::unique_ptr<Core::TelemetrySession> telemetry_session;
131
120 static System s_instance; 132 static System s_instance;
121}; 133};
122 134
@@ -124,4 +136,8 @@ inline ARM_Interface& CPU() {
124 return System::GetInstance().CPU(); 136 return System::GetInstance().CPU();
125} 137}
126 138
139inline TelemetrySession& Telemetry() {
140 return System::GetInstance().TelemetrySession();
141}
142
127} // namespace Core 143} // namespace Core
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
new file mode 100644
index 000000000..ec8f7d95e
--- /dev/null
+++ b/src/core/telemetry_session.cpp
@@ -0,0 +1,24 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/scm_rev.h"
6#include "core/telemetry_session.h"
7
8namespace Core {
9
10TelemetrySession::TelemetrySession() {
11 // TODO(bunnei): Replace with a backend that logs to our web service
12 backend = std::make_unique<Telemetry::NullVisitor>();
13}
14
15TelemetrySession::~TelemetrySession() {
16 // Complete the session, submitting to web service if necessary
17 // This is just a placeholder to wrap up the session once the core completes and this is
18 // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service.
19 field_collection.Accept(*backend);
20 backend->Complete();
21 backend = nullptr;
22}
23
24} // namespace Core
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h
new file mode 100644
index 000000000..39e167868
--- /dev/null
+++ b/src/core/telemetry_session.h
@@ -0,0 +1,38 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include "common/telemetry.h"
9
10namespace Core {
11
12/**
13 * Instruments telemetry for this emulation session. Creates a new set of telemetry fields on each
14 * session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
15 * data to the web service. Submits session data on close.
16 */
17class TelemetrySession : NonCopyable {
18public:
19 TelemetrySession();
20 ~TelemetrySession();
21
22 /**
23 * Wrapper around the Telemetry::FieldCollection::AddField method.
24 * @param type Type of the field to add.
25 * @param name Name of the field to add.
26 * @param value Value for the field to add.
27 */
28 template <typename T>
29 void AddField(Telemetry::FieldType type, const char* name, T value) {
30 field_collection.AddField(type, name, std::move(value));
31 }
32
33private:
34 Telemetry::FieldCollection field_collection; ///< Field collection, tracks all added fields
35 std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields
36};
37
38} // namespace Core