mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-16 16:16:44 +00:00
Improve profiling code
This commit is contained in:
parent
2c2c90ef94
commit
dd3cf77bee
@ -31,6 +31,10 @@
|
|||||||
// Uncomment this line to enable the profiling infrastructure
|
// Uncomment this line to enable the profiling infrastructure
|
||||||
//#define ENABLE_PROFILING 1
|
//#define ENABLE_PROFILING 1
|
||||||
|
|
||||||
|
// Use this define to choose the time threshold in milliseconds above
|
||||||
|
// which a profiling message is printed
|
||||||
|
#define PROFILING_MESSAGE_THRESHOLD 1
|
||||||
|
|
||||||
struct Shader {
|
struct Shader {
|
||||||
Shader() : program(0), texcoord_scale_location(0) {}
|
Shader() : program(0), texcoord_scale_location(0) {}
|
||||||
~Shader() {}
|
~Shader() {}
|
||||||
@ -92,6 +96,9 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
|||||||
static uint64_t ProfilerUnpackTime(uint32_t packedTime);
|
static uint64_t ProfilerUnpackTime(uint32_t packedTime);
|
||||||
static void ProfilerPrintPackedDelta(const char* message, uint32_t packedTimeA, uint32_t packedTimeB);
|
static void ProfilerPrintPackedDelta(const char* message, uint32_t packedTimeA, uint32_t packedTimeB);
|
||||||
static void ProfilerPrintDelta(const char* message, uint64_t timeA, uint64_t timeB);
|
static void ProfilerPrintDelta(const char* message, uint64_t timeA, uint64_t timeB);
|
||||||
|
static void ProfilerPrintPackedDeltaFromNow(const char* message, uint32_t packedTime);
|
||||||
|
static void ProfilerPrintDeltaFromNow(const char* message, uint64_t time);
|
||||||
|
static void ProfilerPrintWarning(const char* message);
|
||||||
|
|
||||||
static void* ConnectionThreadFunc(void* context);
|
static void* ConnectionThreadFunc(void* context);
|
||||||
static void* GamepadThreadFunc(void* context);
|
static void* GamepadThreadFunc(void* context);
|
||||||
|
@ -51,19 +51,38 @@ uint64_t MoonlightInstance::ProfilerUnpackTime(uint32_t packedTime) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void printDeltaAboveThreshold(const char* message, uint32_t delta) {
|
||||||
|
#if defined(ENABLE_PROFILING)
|
||||||
|
if (PROFILING_MESSAGE_THRESHOLD < 0 || delta > PROFILING_MESSAGE_THRESHOLD) {
|
||||||
|
printf("%s: %d ms\n", message, delta);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoonlightInstance::ProfilerPrintPackedDeltaFromNow(const char* message, uint32_t packedTime) {
|
||||||
|
ProfilerPrintPackedDelta(message, packedTime, ProfilerGetPackedMillis());
|
||||||
|
}
|
||||||
|
|
||||||
void MoonlightInstance::ProfilerPrintPackedDelta(const char* message,
|
void MoonlightInstance::ProfilerPrintPackedDelta(const char* message,
|
||||||
uint32_t packedTimeA,
|
uint32_t packedTimeA,
|
||||||
uint32_t packedTimeB) {
|
uint32_t packedTimeB) {
|
||||||
|
printDeltaAboveThreshold(message,
|
||||||
|
(uint32_t)(ProfilerUnpackTime(packedTimeB) -
|
||||||
|
ProfilerUnpackTime(packedTimeA)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoonlightInstance::ProfilerPrintWarning(const char* message) {
|
||||||
#if defined(ENABLE_PROFILING)
|
#if defined(ENABLE_PROFILING)
|
||||||
printf("%s: %d ms\n", message,
|
printf("PROFILING WARNING: %s\n", message);
|
||||||
(uint32_t)(ProfilerUnpackTime(packedTimeB) - ProfilerUnpackTime(packedTimeA)));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoonlightInstance::ProfilerPrintDeltaFromNow(const char* message, uint64_t time) {
|
||||||
|
ProfilerPrintDelta(message, time, ProfilerGetMillis());
|
||||||
|
}
|
||||||
|
|
||||||
void MoonlightInstance::ProfilerPrintDelta(const char* message,
|
void MoonlightInstance::ProfilerPrintDelta(const char* message,
|
||||||
uint64_t timeA,
|
uint64_t timeA,
|
||||||
uint64_t timeB) {
|
uint64_t timeB) {
|
||||||
#if defined(ENABLE_PROFILING)
|
printDeltaAboveThreshold(message, (uint32_t)(timeB - timeA));
|
||||||
printf("%s: %d ms\n", message, (uint32_t)(timeA - timeB));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user