diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 4fcb6b93c1..c12e7b1c63 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "base/timeutil.h" #include "HLE.h" #include #include @@ -344,6 +345,8 @@ inline void hleFinishSyscall(int modulenum, int funcnum) void CallSyscall(u32 op) { + time_update(); + double start = time_now_d(); u32 callno = (op >> 6) & 0xFFFFF; //20 bits int funcnum = callno & 0xFFF; int modulenum = (callno & 0xFF000) >> 12; @@ -365,4 +368,14 @@ void CallSyscall(u32 op) { ERROR_LOG(HLE,"Unimplemented HLE function %s", moduleDB[modulenum].funcTable[funcnum].name); } + time_update(); + double total = time_now_d() - start; + if (total > kernelStats.slowestSyscallTime) { + const char *name = moduleDB[modulenum].funcTable[funcnum].name; + if (0 != strcmp(name, "_sceKernelIdle")) { + kernelStats.slowestSyscallTime = total; + kernelStats.slowestSyscallName = name; + } + } + kernelStats.msInSyscalls += total; } diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 26909f5574..1dae0dd5ab 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -71,6 +71,7 @@ static bool kernelRunning = false; KernelObjectPool kernelObjects; +KernelStats kernelStats; void __KernelInit() { diff --git a/Core/HLE/sceKernel.h b/Core/HLE/sceKernel.h index 0b77682136..52ad5f8ca2 100644 --- a/Core/HLE/sceKernel.h +++ b/Core/HLE/sceKernel.h @@ -377,6 +377,7 @@ public: return t; } } + template T* GetByModuleByEntryAddr(u32 entryAddr) { @@ -410,13 +411,32 @@ public: int GetCount(); private: - enum {maxCount=4096, handleOffset=0x100}; + enum { + maxCount=4096, + handleOffset=0x100 + }; KernelObject *pool[maxCount]; bool occupied[maxCount]; }; extern KernelObjectPool kernelObjects; +struct KernelStats { + void Reset() { + memset(this, 0, sizeof(this)); + } + void ResetFrame() { + msInSyscalls = 0; + slowestSyscallTime = 0; + slowestSyscallName = 0; + } + + double msInSyscalls; + double slowestSyscallTime; + const char *slowestSyscallName; +}; + +extern KernelStats kernelStats; void Register_ThreadManForUser(); void Register_LoadExecForUser();