Add kernelstats

Useful for finding out if some syscall takes unexpectedly much CPU.
This commit is contained in:
Henrik Rydgard 2013-01-10 23:42:46 +01:00
parent 10f69ed000
commit f3749d8abe
3 changed files with 35 additions and 1 deletions

View File

@ -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 <map>
#include <vector>
@ -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;
}

View File

@ -71,6 +71,7 @@
static bool kernelRunning = false;
KernelObjectPool kernelObjects;
KernelStats kernelStats;
void __KernelInit()
{

View File

@ -377,6 +377,7 @@ public:
return t;
}
}
template <class T>
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();