feature: Added profiler which outputs to tty, removed subdivision entirely - to be remade later
This commit is contained in:
32
src/profiler.cpp
Normal file
32
src/profiler.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "profiler.hh"
|
||||
|
||||
#include "psyqo/xprintf.h"
|
||||
|
||||
using namespace psxsplash::debug;
|
||||
|
||||
void pcsxRegisterVariable(void* address, const char* name) {
|
||||
register void* a0 asm("a0") = address;
|
||||
register const char* a1 asm("a1") = name;
|
||||
__asm__ volatile("sb %0, 0x2081(%1)" : : "r"(255), "r"(0x1f800000), "r"(a0), "r"(a1));
|
||||
}
|
||||
|
||||
void Profiler::initialize() {
|
||||
reset();
|
||||
|
||||
pcsxRegisterVariable(§ionTimes[0], "profiler.rendering");
|
||||
pcsxRegisterVariable(§ionTimes[1], "profiler.lua");
|
||||
pcsxRegisterVariable(§ionTimes[2], "profiler.controls");
|
||||
pcsxRegisterVariable(§ionTimes[3], "profiler.navmesh");
|
||||
}
|
||||
|
||||
void Profiler::reset() {
|
||||
for (auto &time : sectionTimes) {
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Profiler::dumpToTTY() {
|
||||
printf("profiler.rendering:%d,profiler.lua:%d,profiler.controls:%d,profiler.navmesh:%d\n", sectionTimes[0], sectionTimes[1], sectionTimes[2], sectionTimes[3]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user