History

Updating the platform lib, implementing the first version of the profiler and exposing all these through the PlatformInfoScriptingInterface

Sam Gateau committed 7 years ago

Commit 5001a041 parent 3ce790b20 files · +646 −181Browse files

Showing the changes to interface/src/scripting/PlatformInfoScriptingInterface.cpp (1 of 20 files). Show all

Unified · Split

interface/src/scripting/PlatformInfoScriptingInterface.cpp+63−0
@@ -10,6 +10,9 @@ · 9 unmodified lines
1010 #include <shared/GlobalAppProperties.h>
1111 #include <thread>
1212
13+#include <platform/Platform.h>
14+#include <platform/Profiler.h>
15+
1316 #ifdef Q_OS_WIN
1417 #include <Windows.h>
1518 #elif defined Q_OS_MAC
@@ -21,6 +24,17 @@ PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() { · 5 unmodified lines
2124 return &sharedInstance;
2225 }
2326
27+
28+PlatformInfoScriptingInterface::PlatformInfoScriptingInterface() {
29+ platform::create();
30+ if (!platform::enumeratePlatform()) {
31+ }
32+}
33+
34+PlatformInfoScriptingInterface::~PlatformInfoScriptingInterface() {
35+ platform::destroy();
36+}
37+
2438 QString PlatformInfoScriptingInterface::getOperatingSystemType() {
2539 #ifdef Q_OS_WIN
2640 return "WINDOWS";
@@ -149,3 +163,52 @@ bool PlatformInfoScriptingInterface::isStandalone() { · 122 unmodified lines
149163 return qApp->property(hifi::properties::STANDALONE).toBool();
150164 #endif
151165 }
166+
167+int PlatformInfoScriptingInterface::getNumCPUs() {
168+ return platform::getNumCPUs();
169+}
170+
171+QString PlatformInfoScriptingInterface::getCPU(int index) {
172+ auto desc = platform::getCPU(index);
173+ return QString(desc.dump().c_str());
174+}
175+
176+int PlatformInfoScriptingInterface::getNumGPUs() {
177+ return platform::getNumGPUs();
178+}
179+
180+QString PlatformInfoScriptingInterface::getGPU(int index) {
181+ auto desc = platform::getGPU(index);
182+ return QString(desc.dump().c_str());
183+}
184+
185+int PlatformInfoScriptingInterface::getNumDisplays() {
186+ return platform::getNumDisplays();
187+}
188+
189+QString PlatformInfoScriptingInterface::getDisplay(int index) {
190+ auto desc = platform::getDisplay(index);
191+ return QString(desc.dump().c_str());
192+}
193+
194+QString PlatformInfoScriptingInterface::getMemory() {
195+ auto desc = platform::getMemory(0);
196+ return QString(desc.dump().c_str());
197+}
198+
199+QString PlatformInfoScriptingInterface::getComputer() {
200+ auto desc = platform::getComputer();
201+ return QString(desc.dump().c_str());
202+}
203+
204+
205+PlatformInfoScriptingInterface::PlatformTier PlatformInfoScriptingInterface::getTierProfiled() {
206+ return (PlatformInfoScriptingInterface::PlatformTier) platform::Profiler::profilePlatform();
207+}
208+
209+QStringList PlatformInfoScriptingInterface::getPlatformTierNames() {
210+ static const QStringList platformTierNames = { "UNKNWON", "LOW", "MID", "HIGH" };
211+ return platformTierNames;
212+}
213+
214+