Merge pull request #1369 from Sonicadvance1/enable-profiling
Enables block profiling in the UI on non x86 targets.
This commit is contained in:
commit
a9f0bd72d2
|
@ -134,31 +134,32 @@ namespace JitInterface
|
||||||
void WriteProfileResults(const std::string& filename)
|
void WriteProfileResults(const std::string& filename)
|
||||||
{
|
{
|
||||||
// Can't really do this with no jit core available
|
// Can't really do this with no jit core available
|
||||||
#if _M_X86
|
if (!jit)
|
||||||
|
return;
|
||||||
|
|
||||||
std::vector<BlockStat> stats;
|
std::vector<BlockStat> stats;
|
||||||
stats.reserve(jit->GetBlockCache()->GetNumBlocks());
|
stats.reserve(jit->GetBlockCache()->GetNumBlocks());
|
||||||
u64 cost_sum = 0;
|
u64 cost_sum = 0;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u64 timecost_sum = 0;
|
u64 timecost_sum = 0;
|
||||||
u64 countsPerSec;
|
u64 countsPerSec;
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER *)&countsPerSec);
|
QueryPerformanceFrequency((LARGE_INTEGER *)&countsPerSec);
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < jit->GetBlockCache()->GetNumBlocks(); i++)
|
for (int i = 0; i < jit->GetBlockCache()->GetNumBlocks(); i++)
|
||||||
{
|
{
|
||||||
const JitBlock *block = jit->GetBlockCache()->GetBlock(i);
|
const JitBlock *block = jit->GetBlockCache()->GetBlock(i);
|
||||||
// Rough heuristic. Mem instructions should cost more.
|
// Rough heuristic. Mem instructions should cost more.
|
||||||
u64 cost = block->originalSize * (block->runCount / 4);
|
u64 cost = block->originalSize * (block->runCount / 4);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u64 timecost = block->ticCounter;
|
u64 timecost = block->ticCounter;
|
||||||
#endif
|
#endif
|
||||||
// Todo: tweak.
|
// Todo: tweak.
|
||||||
if (block->runCount >= 1)
|
if (block->runCount >= 1)
|
||||||
stats.push_back(BlockStat(i, cost));
|
stats.push_back(BlockStat(i, cost));
|
||||||
cost_sum += cost;
|
cost_sum += cost;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
timecost_sum += timecost;
|
timecost_sum += timecost;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(stats.begin(), stats.end());
|
sort(stats.begin(), stats.end());
|
||||||
|
@ -176,19 +177,18 @@ namespace JitInterface
|
||||||
{
|
{
|
||||||
std::string name = g_symbolDB.GetDescription(block->originalAddress);
|
std::string name = g_symbolDB.GetDescription(block->originalAddress);
|
||||||
double percent = 100.0 * (double)stat.cost / (double)cost_sum;
|
double percent = 100.0 * (double)stat.cost / (double)cost_sum;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
double timePercent = 100.0 * (double)block->ticCounter / (double)timecost_sum;
|
double timePercent = 100.0 * (double)block->ticCounter / (double)timecost_sum;
|
||||||
fprintf(f.GetHandle(), "%08x\t%s\t%" PRIu64 "\t%" PRIu64 "\t%.2lf\t%llf\t%lf\t%i\n",
|
fprintf(f.GetHandle(), "%08x\t%s\t%" PRIu64 "\t%" PRIu64 "\t%.2lf\t%llf\t%lf\t%i\n",
|
||||||
block->originalAddress, name.c_str(), stat.cost,
|
block->originalAddress, name.c_str(), stat.cost,
|
||||||
block->ticCounter, percent, timePercent,
|
block->ticCounter, percent, timePercent,
|
||||||
(double)block->ticCounter*1000.0/(double)countsPerSec, block->codeSize);
|
(double)block->ticCounter*1000.0/(double)countsPerSec, block->codeSize);
|
||||||
#else
|
#else
|
||||||
fprintf(f.GetHandle(), "%08x\t%s\t%" PRIu64 "\t???\t%.2lf\t???\t???\t%i\n",
|
fprintf(f.GetHandle(), "%08x\t%s\t%" PRIu64 "\t???\t%.2lf\t???\t???\t%i\n",
|
||||||
block->originalAddress, name.c_str(), stat.cost, percent, block->codeSize);
|
block->originalAddress, name.c_str(), stat.cost, percent, block->codeSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
bool HandleFault(uintptr_t access_address, SContext* ctx)
|
bool HandleFault(uintptr_t access_address, SContext* ctx)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue