sorted profile table

extensions
Steven Massey 4 years ago
parent f209be8663
commit a0c42219f8

@ -18,7 +18,7 @@ M3Result EnsureCodePageNumLines (IM3Compilation o, u32 i_numLines);
M3Result EmitOp (IM3Compilation o, IM3Operation i_operation); M3Result EmitOp (IM3Compilation o, IM3Operation i_operation);
void EmitConstant (IM3Compilation o, const u64 i_immediate); void EmitConstant (IM3Compilation o, const u64 i_immediate);
void EmitConstant64 (IM3Compilation o, const u64 i_const); void EmitConstant64 (IM3Compilation o, const u64 i_const);
void EmitSlotOffset (IM3Compilation o, const i32 i_offset); void EmitSlotOffset (IM3Compilation o, const i32 i_offset);
void EmitPointer (IM3Compilation o, const void * const i_pointer); void EmitPointer (IM3Compilation o, const void * const i_pointer);
void * ReservePointer (IM3Compilation o); void * ReservePointer (IM3Compilation o);

@ -184,6 +184,8 @@ void m3_FreeRuntime (IM3Runtime i_runtime)
{ {
if (i_runtime) if (i_runtime)
{ {
m3_PrintProfilerInfo ();
ReleaseRuntime (i_runtime); ReleaseRuntime (i_runtime);
m3Free (i_runtime); m3Free (i_runtime);
} }

@ -331,13 +331,13 @@ d_m3OpDef (BranchTable)
d_m3OpDef (SetRegister_##TYPE) \ d_m3OpDef (SetRegister_##TYPE) \
{ \ { \
REG = slot (TYPE); \ REG = slot (TYPE); \
nextOp (); \ nextOp (); \
} \ } \
\ \
d_m3OpDef (SetSlot_##TYPE) \ d_m3OpDef (SetSlot_##TYPE) \
{ \ { \
slot (TYPE) = (TYPE) REG; \ slot (TYPE) = (TYPE) REG; \
nextOp (); \ nextOp (); \
} \ } \
\ \
d_m3OpDef (PreserveSetSlot_##TYPE) \ d_m3OpDef (PreserveSetSlot_##TYPE) \
@ -348,7 +348,7 @@ d_m3OpDef (PreserveSetSlot_##TYPE) \
* preserve = * stack; \ * preserve = * stack; \
* stack = (TYPE) REG; \ * stack = (TYPE) REG; \
\ \
nextOp (); \ nextOp (); \
} }
d_m3SetRegisterSetSlot (i32, _r0) d_m3SetRegisterSetSlot (i32, _r0)
@ -440,7 +440,7 @@ d_m3OpDef (DumpStack)
# if d_m3EnableOpProfiling # if d_m3EnableOpProfiling
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
M3ProfilerSlot s_opProfilerCounts [c_m3ProfilerSlotMask] = {}; M3ProfilerSlot s_opProfilerCounts [c_m3ProfilerSlotMask + 1] = {};
void ProfileHit (cstr_t i_operationName) void ProfileHit (cstr_t i_operationName)
{ {
@ -460,15 +460,34 @@ void ProfileHit (cstr_t i_operationName)
slot->hitCount++; slot->hitCount++;
} }
void m3_PrintProfilerInfo () void m3_PrintProfilerInfo ()
{ {
for (u32 i = 0; i <= c_m3ProfilerSlotMask; ++i) M3ProfilerSlot dummy;
M3ProfilerSlot * maxSlot = & dummy;
do
{ {
M3ProfilerSlot * slot = & s_opProfilerCounts [i]; maxSlot->hitCount = 0;
for (u32 i = 0; i <= c_m3ProfilerSlotMask; ++i)
{
M3ProfilerSlot * slot = & s_opProfilerCounts [i];
if (slot->opName)
{
if (slot->hitCount > maxSlot->hitCount)
maxSlot = slot;
}
}
if (slot->opName) if (maxSlot->opName)
printf ("%13llu %s\n", slot->hitCount, slot->opName); {
fprintf (stderr, "%13llu %s\n", maxSlot->hitCount, maxSlot->opName);
maxSlot->opName = NULL;
}
} }
while (maxSlot->hitCount);
} }
# else # else

Loading…
Cancel
Save