mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add way to print some block bloat stats.
This commit is contained in:
parent
115486e431
commit
59d0baca93
4 changed files with 64 additions and 0 deletions
|
@ -654,3 +654,31 @@ int JitBlockCache::GetBlockExitSize() {
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void JitBlockCache::ComputeStats(BlockCacheStats &bcStats) {
|
||||
double totalBloat = 0.0;
|
||||
double maxBloat = 0.0;
|
||||
double minBloat = 1000000000.0;
|
||||
for (int i = 0; i < num_blocks_; i++) {
|
||||
JitBlock *b = GetBlock(i);
|
||||
double codeSize = (double)b->codeSize;
|
||||
if (codeSize == 0)
|
||||
continue;
|
||||
double origSize = (double)(4 * b->originalSize);
|
||||
double bloat = codeSize / origSize;
|
||||
if (bloat < minBloat) {
|
||||
minBloat = bloat;
|
||||
bcStats.minBloatBlock = b->originalAddress;
|
||||
}
|
||||
if (bloat > maxBloat) {
|
||||
maxBloat = bloat;
|
||||
bcStats.maxBloatBlock = b->originalAddress;
|
||||
}
|
||||
totalBloat += bloat;
|
||||
bcStats.bloatMap[bloat] = b->originalAddress;
|
||||
}
|
||||
bcStats.numBlocks = num_blocks_;
|
||||
bcStats.minBloat = minBloat;
|
||||
bcStats.maxBloat = maxBloat;
|
||||
bcStats.avgBloat = totalBloat / (double)num_blocks_;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,16 @@ const int MAX_JIT_BLOCK_EXITS = 2;
|
|||
const int MAX_JIT_BLOCK_EXITS = 8;
|
||||
#endif
|
||||
|
||||
struct BlockCacheStats {
|
||||
int numBlocks;
|
||||
float avgBloat; // In code bytes, not instructions!
|
||||
float minBloat;
|
||||
u32 minBloatBlock;
|
||||
float maxBloat;
|
||||
u32 maxBloatBlock;
|
||||
std::map<float, u32> bloatMap;
|
||||
};
|
||||
|
||||
// Define this in order to get VTune profile support for the Jit generated code.
|
||||
// Add the VTune include/lib directories to the project directories to get this to build.
|
||||
// #define USE_VTUNE
|
||||
|
@ -114,6 +124,7 @@ public:
|
|||
void Reset();
|
||||
|
||||
bool IsFull() const;
|
||||
void ComputeStats(BlockCacheStats &bcStats);
|
||||
|
||||
// Code Cache
|
||||
JitBlock *GetBlock(int block_num);
|
||||
|
|
|
@ -567,6 +567,7 @@ void JitCompareScreen::CreateViews() {
|
|||
leftColumn->Add(new Choice(de->T("Random")))->OnClick.Handle(this, &JitCompareScreen::OnRandomBlock);
|
||||
leftColumn->Add(new Choice(de->T("FPU")))->OnClick.Handle(this, &JitCompareScreen::OnRandomFPUBlock);
|
||||
leftColumn->Add(new Choice(de->T("VFPU")))->OnClick.Handle(this, &JitCompareScreen::OnRandomVFPUBlock);
|
||||
leftColumn->Add(new Choice(d->T("Stats")))->OnClick.Handle(this, &JitCompareScreen::OnShowStats);
|
||||
leftColumn->Add(new Choice(d->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
blockName_ = leftColumn->Add(new TextView(de->T("No block")));
|
||||
blockAddr_ = leftColumn->Add(new TextEdit("", "", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
|
@ -648,6 +649,29 @@ UI::EventReturn JitCompareScreen::OnAddressChange(UI::EventParams &e) {
|
|||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn JitCompareScreen::OnShowStats(UI::EventParams &e) {
|
||||
JitBlockCache *blockCache = MIPSComp::jit->GetBlockCache();
|
||||
BlockCacheStats bcStats;
|
||||
blockCache->ComputeStats(bcStats);
|
||||
NOTICE_LOG(JIT, "Num blocks: %i", bcStats.numBlocks);
|
||||
NOTICE_LOG(JIT, "Average Bloat: %0.2f%%", 100 * bcStats.avgBloat);
|
||||
NOTICE_LOG(JIT, "Min Bloat: %0.2f%% (%08x)", 100 * bcStats.minBloat, bcStats.minBloatBlock);
|
||||
NOTICE_LOG(JIT, "Max Bloat: %0.2f%% (%08x)", 100 * bcStats.maxBloat, bcStats.maxBloatBlock);
|
||||
|
||||
int ctr = 0, sz = (int)bcStats.bloatMap.size();
|
||||
for (auto iter : bcStats.bloatMap) {
|
||||
if (ctr < 10 || ctr > sz - 10) {
|
||||
NOTICE_LOG(JIT, "%08x: %f", iter.second, iter.first);
|
||||
} else if (ctr == 10) {
|
||||
NOTICE_LOG(JIT, "...");
|
||||
}
|
||||
ctr++;
|
||||
}
|
||||
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
||||
UI::EventReturn JitCompareScreen::OnSelectBlock(UI::EventParams &e) {
|
||||
I18NCategory *de = GetI18NCategory("Developer");
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ private:
|
|||
UI::EventReturn OnNextBlock(UI::EventParams &e);
|
||||
UI::EventReturn OnBlockAddress(UI::EventParams &e);
|
||||
UI::EventReturn OnAddressChange(UI::EventParams &e);
|
||||
UI::EventReturn OnShowStats(UI::EventParams &e);
|
||||
|
||||
int currentBlock_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue