diff options
| author | 2018-08-20 19:43:17 -0400 | |
|---|---|---|
| committer | 2018-08-20 19:43:17 -0400 | |
| commit | b1d238bbb8c7ff73f4be1511049059721e2a2404 (patch) | |
| tree | e7864372b8c1a79c93350e212f436c296ae6954f /src | |
| parent | Merge pull request #1104 from Subv/instanced_arrays (diff) | |
| parent | common/telemetry: Migrate core-independent info gathering to common (diff) | |
| download | yuzu-b1d238bbb8c7ff73f4be1511049059721e2a2404.tar.gz yuzu-b1d238bbb8c7ff73f4be1511049059721e2a2404.tar.xz yuzu-b1d238bbb8c7ff73f4be1511049059721e2a2404.zip | |
Merge pull request #1064 from lioncash/telemetry
common/telemetry: Migrate core-independent info gathering to common
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/telemetry.cpp | 65 | ||||
| -rw-r--r-- | src/common/telemetry.h | 12 | ||||
| -rw-r--r-- | src/core/telemetry_session.cpp | 69 |
3 files changed, 84 insertions, 62 deletions
diff --git a/src/common/telemetry.cpp b/src/common/telemetry.cpp index bf1f54886..f53a8d193 100644 --- a/src/common/telemetry.cpp +++ b/src/common/telemetry.cpp | |||
| @@ -3,8 +3,15 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cstring> | ||
| 7 | #include "common/assert.h" | ||
| 8 | #include "common/scm_rev.h" | ||
| 6 | #include "common/telemetry.h" | 9 | #include "common/telemetry.h" |
| 7 | 10 | ||
| 11 | #ifdef ARCHITECTURE_x86_64 | ||
| 12 | #include "common/x64/cpu_detect.h" | ||
| 13 | #endif | ||
| 14 | |||
| 8 | namespace Telemetry { | 15 | namespace Telemetry { |
| 9 | 16 | ||
| 10 | void FieldCollection::Accept(VisitorInterface& visitor) const { | 17 | void FieldCollection::Accept(VisitorInterface& visitor) const { |
| @@ -37,4 +44,62 @@ template class Field<std::string>; | |||
| 37 | template class Field<const char*>; | 44 | template class Field<const char*>; |
| 38 | template class Field<std::chrono::microseconds>; | 45 | template class Field<std::chrono::microseconds>; |
| 39 | 46 | ||
| 47 | #ifdef ARCHITECTURE_x86_64 | ||
| 48 | static const char* CpuVendorToStr(Common::CPUVendor vendor) { | ||
| 49 | switch (vendor) { | ||
| 50 | case Common::CPUVendor::INTEL: | ||
| 51 | return "Intel"; | ||
| 52 | case Common::CPUVendor::AMD: | ||
| 53 | return "Amd"; | ||
| 54 | case Common::CPUVendor::OTHER: | ||
| 55 | return "Other"; | ||
| 56 | } | ||
| 57 | UNREACHABLE(); | ||
| 58 | } | ||
| 59 | #endif | ||
| 60 | |||
| 61 | void AppendBuildInfo(FieldCollection& fc) { | ||
| 62 | const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr}; | ||
| 63 | fc.AddField(FieldType::App, "Git_IsDirty", is_git_dirty); | ||
| 64 | fc.AddField(FieldType::App, "Git_Branch", Common::g_scm_branch); | ||
| 65 | fc.AddField(FieldType::App, "Git_Revision", Common::g_scm_rev); | ||
| 66 | fc.AddField(FieldType::App, "BuildDate", Common::g_build_date); | ||
| 67 | fc.AddField(FieldType::App, "BuildName", Common::g_build_name); | ||
| 68 | } | ||
| 69 | |||
| 70 | void AppendCPUInfo(FieldCollection& fc) { | ||
| 71 | #ifdef ARCHITECTURE_x86_64 | ||
| 72 | fc.AddField(FieldType::UserSystem, "CPU_Model", Common::GetCPUCaps().cpu_string); | ||
| 73 | fc.AddField(FieldType::UserSystem, "CPU_BrandString", Common::GetCPUCaps().brand_string); | ||
| 74 | fc.AddField(FieldType::UserSystem, "CPU_Vendor", CpuVendorToStr(Common::GetCPUCaps().vendor)); | ||
| 75 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AES", Common::GetCPUCaps().aes); | ||
| 76 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX", Common::GetCPUCaps().avx); | ||
| 77 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX2", Common::GetCPUCaps().avx2); | ||
| 78 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI1", Common::GetCPUCaps().bmi1); | ||
| 79 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI2", Common::GetCPUCaps().bmi2); | ||
| 80 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA", Common::GetCPUCaps().fma); | ||
| 81 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA4", Common::GetCPUCaps().fma4); | ||
| 82 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE", Common::GetCPUCaps().sse); | ||
| 83 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE2", Common::GetCPUCaps().sse2); | ||
| 84 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE3", Common::GetCPUCaps().sse3); | ||
| 85 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSSE3", Common::GetCPUCaps().ssse3); | ||
| 86 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE41", Common::GetCPUCaps().sse4_1); | ||
| 87 | fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE42", Common::GetCPUCaps().sse4_2); | ||
| 88 | #else | ||
| 89 | fc.AddField(FieldType::UserSystem, "CPU_Model", "Other"); | ||
| 90 | #endif | ||
| 91 | } | ||
| 92 | |||
| 93 | void AppendOSInfo(FieldCollection& fc) { | ||
| 94 | #ifdef __APPLE__ | ||
| 95 | fc.AddField(FieldType::UserSystem, "OsPlatform", "Apple"); | ||
| 96 | #elif defined(_WIN32) | ||
| 97 | fc.AddField(FieldType::UserSystem, "OsPlatform", "Windows"); | ||
| 98 | #elif defined(__linux__) || defined(linux) || defined(__linux) | ||
| 99 | fc.AddField(FieldType::UserSystem, "OsPlatform", "Linux"); | ||
| 100 | #else | ||
| 101 | fc.AddField(FieldType::UserSystem, "OsPlatform", "Unknown"); | ||
| 102 | #endif | ||
| 103 | } | ||
| 104 | |||
| 40 | } // namespace Telemetry | 105 | } // namespace Telemetry |
diff --git a/src/common/telemetry.h b/src/common/telemetry.h index 3bab75b59..8d6ab986b 100644 --- a/src/common/telemetry.h +++ b/src/common/telemetry.h | |||
| @@ -180,4 +180,16 @@ struct NullVisitor : public VisitorInterface { | |||
| 180 | void Complete() override {} | 180 | void Complete() override {} |
| 181 | }; | 181 | }; |
| 182 | 182 | ||
| 183 | /// Appends build-specific information to the given FieldCollection, | ||
| 184 | /// such as branch name, revision hash, etc. | ||
| 185 | void AppendBuildInfo(FieldCollection& fc); | ||
| 186 | |||
| 187 | /// Appends CPU-specific information to the given FieldCollection, | ||
| 188 | /// such as instruction set extensions, etc. | ||
| 189 | void AppendCPUInfo(FieldCollection& fc); | ||
| 190 | |||
| 191 | /// Appends OS-specific information to the given FieldCollection, | ||
| 192 | /// such as platform name, etc. | ||
| 193 | void AppendOSInfo(FieldCollection& fc); | ||
| 194 | |||
| 183 | } // namespace Telemetry | 195 | } // namespace Telemetry |
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 69aa7a7be..7e4584fc2 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -2,34 +2,16 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cstring> | ||
| 6 | |||
| 7 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/common_types.h" | ||
| 8 | #include "common/file_util.h" | 7 | #include "common/file_util.h" |
| 9 | #include "common/scm_rev.h" | 8 | |
| 10 | #ifdef ARCHITECTURE_x86_64 | ||
| 11 | #include "common/x64/cpu_detect.h" | ||
| 12 | #endif | ||
| 13 | #include "core/core.h" | 9 | #include "core/core.h" |
| 14 | #include "core/settings.h" | 10 | #include "core/settings.h" |
| 15 | #include "core/telemetry_session.h" | 11 | #include "core/telemetry_session.h" |
| 16 | 12 | ||
| 17 | namespace Core { | 13 | namespace Core { |
| 18 | 14 | ||
| 19 | #ifdef ARCHITECTURE_x86_64 | ||
| 20 | static const char* CpuVendorToStr(Common::CPUVendor vendor) { | ||
| 21 | switch (vendor) { | ||
| 22 | case Common::CPUVendor::INTEL: | ||
| 23 | return "Intel"; | ||
| 24 | case Common::CPUVendor::AMD: | ||
| 25 | return "Amd"; | ||
| 26 | case Common::CPUVendor::OTHER: | ||
| 27 | return "Other"; | ||
| 28 | } | ||
| 29 | UNREACHABLE(); | ||
| 30 | } | ||
| 31 | #endif | ||
| 32 | |||
| 33 | static u64 GenerateTelemetryId() { | 15 | static u64 GenerateTelemetryId() { |
| 34 | u64 telemetry_id{}; | 16 | u64 telemetry_id{}; |
| 35 | return telemetry_id; | 17 | return telemetry_id; |
| @@ -112,48 +94,11 @@ TelemetrySession::TelemetrySession() { | |||
| 112 | } | 94 | } |
| 113 | 95 | ||
| 114 | // Log application information | 96 | // Log application information |
| 115 | const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr}; | 97 | Telemetry::AppendBuildInfo(field_collection); |
| 116 | AddField(Telemetry::FieldType::App, "Git_IsDirty", is_git_dirty); | 98 | |
| 117 | AddField(Telemetry::FieldType::App, "Git_Branch", Common::g_scm_branch); | 99 | // Log user system information |
| 118 | AddField(Telemetry::FieldType::App, "Git_Revision", Common::g_scm_rev); | 100 | Telemetry::AppendCPUInfo(field_collection); |
| 119 | AddField(Telemetry::FieldType::App, "BuildDate", Common::g_build_date); | 101 | Telemetry::AppendOSInfo(field_collection); |
| 120 | AddField(Telemetry::FieldType::App, "BuildName", Common::g_build_name); | ||
| 121 | |||
| 122 | // Log user system information | ||
| 123 | #ifdef ARCHITECTURE_x86_64 | ||
| 124 | AddField(Telemetry::FieldType::UserSystem, "CPU_Model", Common::GetCPUCaps().cpu_string); | ||
| 125 | AddField(Telemetry::FieldType::UserSystem, "CPU_BrandString", | ||
| 126 | Common::GetCPUCaps().brand_string); | ||
| 127 | AddField(Telemetry::FieldType::UserSystem, "CPU_Vendor", | ||
| 128 | CpuVendorToStr(Common::GetCPUCaps().vendor)); | ||
| 129 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_AES", Common::GetCPUCaps().aes); | ||
| 130 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_AVX", Common::GetCPUCaps().avx); | ||
| 131 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_AVX2", Common::GetCPUCaps().avx2); | ||
| 132 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_BMI1", Common::GetCPUCaps().bmi1); | ||
| 133 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_BMI2", Common::GetCPUCaps().bmi2); | ||
| 134 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_FMA", Common::GetCPUCaps().fma); | ||
| 135 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_FMA4", Common::GetCPUCaps().fma4); | ||
| 136 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSE", Common::GetCPUCaps().sse); | ||
| 137 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSE2", Common::GetCPUCaps().sse2); | ||
| 138 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSE3", Common::GetCPUCaps().sse3); | ||
| 139 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSSE3", | ||
| 140 | Common::GetCPUCaps().ssse3); | ||
| 141 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSE41", | ||
| 142 | Common::GetCPUCaps().sse4_1); | ||
| 143 | AddField(Telemetry::FieldType::UserSystem, "CPU_Extension_x64_SSE42", | ||
| 144 | Common::GetCPUCaps().sse4_2); | ||
| 145 | #else | ||
| 146 | AddField(Telemetry::FieldType::UserSystem, "CPU_Model", "Other"); | ||
| 147 | #endif | ||
| 148 | #ifdef __APPLE__ | ||
| 149 | AddField(Telemetry::FieldType::UserSystem, "OsPlatform", "Apple"); | ||
| 150 | #elif defined(_WIN32) | ||
| 151 | AddField(Telemetry::FieldType::UserSystem, "OsPlatform", "Windows"); | ||
| 152 | #elif defined(__linux__) || defined(linux) || defined(__linux) | ||
| 153 | AddField(Telemetry::FieldType::UserSystem, "OsPlatform", "Linux"); | ||
| 154 | #else | ||
| 155 | AddField(Telemetry::FieldType::UserSystem, "OsPlatform", "Unknown"); | ||
| 156 | #endif | ||
| 157 | 102 | ||
| 158 | // Log user configuration information | 103 | // Log user configuration information |
| 159 | AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit", Settings::values.use_cpu_jit); | 104 | AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit", Settings::values.use_cpu_jit); |