Refactor SWWMHandler profiling routines.

This commit is contained in:
Mari the Deer 2022-02-25 16:51:20 +01:00
commit f6b891c9fe
7 changed files with 104 additions and 74 deletions

View file

@ -390,12 +390,12 @@ extend Class SWWMHandler
override void WorldThingDamaged( WorldEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
if ( e.Damage > 0 ) DoDamageHandling(e);
if ( e.DamageSource && (e.DamageSource != e.Thing) ) DoCombatHit(e);
if ( (e.Thing.Health > 0) || e.Thing.bKilled || e.Thing.bCorpse )
{
if ( profiling ) worldthingdamaged_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDAMAGED);
return;
}
DoGibThing(e);
@ -406,10 +406,10 @@ extend Class SWWMHandler
e.DamageSource.DamageMobj(null,null,Actor.TELEFRAG_DAMAGE,'EndLevel');
if ( !e.Thing.player && !e.Thing.bIsMonster && !e.Thing.bCountKill && !(e.Thing is 'ScriptedMarine') )
{
if ( profiling ) worldthingdamaged_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDAMAGED);
return;
}
DoKillScoring(e);
if ( profiling ) worldthingdamaged_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDAMAGED);
}
}

View file

@ -313,15 +313,13 @@ extend Class SWWMHandler
}
bprofiletics = profiletics = (e.Args[0]<=0)?10:e.Args[0];
profiling = true;
worldtick_ms = 0;
worldthingspawned_ms = 0;
worldthingdestroyed_ms = 0;
worldthingdied_ms = 0;
worldthingdamaged_ms = 0;
worldthingrevived_ms = 0;
checkreplacement_ms = 0;
checkreplacee_ms = 0;
Console.Printf("Gathering data for %d tic(s)...",bprofiletics);
for ( int i=0; i<8; i++ )
{
prof_ms[i] = 0;
prof_avg[i] = 0;
prof_calls[i] = 0;
}
Console.Printf("Gathering data for %d tic%s...",bprofiletics,(bprofiletics>1)?"s":"");
return;
}
if ( e.IsManual ) return;

View file

@ -270,18 +270,18 @@ extend Class SWWMHandler
override void CheckReplacee( ReplacedEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
if ( e.Replacement is 'DSparilHax' )
e.Replacee = 'Sorcerer2';
// drla stuff, needed so boss deaths work
if ( !hasdrlamonsters )
{
if ( profiling ) checkreplacee_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEE);
return;
}
let rep = GetDRLAReplacee(e.Replacement);
if ( rep ) e.Replacee = rep;
if ( profiling ) checkreplacee_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEE);
}
private Class<Actor> GetDRLAReplacement( Class<Actor> a )
@ -549,11 +549,11 @@ extend Class SWWMHandler
override void CheckReplacement( ReplaceEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
// respect final replacements
if ( e.IsFinal )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
// DRLA Monsters stuff
@ -564,7 +564,7 @@ extend Class SWWMHandler
{
e.Replacement = rep;
e.IsFinal = true;
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
}
@ -576,7 +576,7 @@ extend Class SWWMHandler
{
if ( SWWMUtility.CheckDehackery(e.Replacee) )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
e.Replacement = 'SWWMHangingKeen';
@ -585,7 +585,7 @@ extend Class SWWMHandler
{
if ( SWWMUtility.CheckDehackery(e.Replacee) )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
e.Replacement = 'SWWMBossBrain';
@ -594,7 +594,7 @@ extend Class SWWMHandler
{
if ( !equinoxhack && (level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043") )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return; // don't replace red key in Equinox MAP13
}
e.Replacement = 'SWWMRedCard';
@ -706,12 +706,12 @@ extend Class SWWMHandler
else if ( e.Replacee is 'ArtiTeleport' ) e.Replacement = 'SafetyTether';
else
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
// this last part is kind of ugly, but it works
// guarantees that OUR replacements are all final
e.IsFinal = true;
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
}
}

View file

@ -13,7 +13,7 @@ extend Class SWWMHandler
override void WorldThingRevived( WorldEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
// reattach combat tracker
if ( !swwm_notrack && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER) && !(e.Thing is 'LampMoth') && !(e.Thing is 'CompanionLamp') )
SWWMCombatTracker.Spawn(e.Thing);
@ -27,7 +27,7 @@ extend Class SWWMHandler
}
if ( !(e.Thing is 'PlayerPawn') )
{
if ( profiling ) worldthingrevived_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGREVIVED);
return;
}
// reset some vars
@ -41,7 +41,7 @@ extend Class SWWMHandler
// reset uptime since player had just died
SWWMStats s = SWWMStats.Find(e.Thing.player);
if ( s ) s.lastspawn = level.totaltime;
if ( profiling ) worldthingrevived_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGREVIVED);
}
private bool HexenMap40()
@ -76,7 +76,7 @@ extend Class SWWMHandler
override void WorldThingDied( WorldEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
if ( e.Thing.default.bISMONSTER && ((e.Thing.default.bBOSS) || (e.Thing.GetSpawnHealth() >= 1000) || e.Thing.FindInventory("BossMarker")) && (alreadygold.Find(e.Thing) == alreadygold.Size()) )
{
// make sure we can't farm drops from revivable enemies
@ -142,7 +142,7 @@ extend Class SWWMHandler
bool gotgibbed = (!e.Thing.bDONTGIB && ((e.Inflictor && e.Inflictor.bEXTREMEDEATH) || (e.DamageSource && e.DamageSource.bEXTREMEDEATH) || (e.DamageType == 'Extreme') || (e.Thing.Health < gibhealth)) && (!e.Inflictor || !e.Inflictor.bNOEXTREMEDEATH) && (!e.DamageSource || !e.DamageSource.bNOEXTREMEDEATH));
if ( !gotgibbed )
{
if ( profiling ) worldthingdied_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDIED);
return;
}
if ( (e.Thing.GetClass() == "Demon") || (e.Thing.GetClass() == "Spectre") )
@ -161,7 +161,7 @@ extend Class SWWMHandler
ExtraGibDeaths.GibThis(e.Thing,"ArachXDeath");
else if ( e.Thing.GetClass() == "Fatso" )
ExtraGibDeaths.GibThis(e.Thing,"FatsoXDeath");
if ( profiling ) worldthingdied_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDIED);
}
private void DoKeyTagFix( Actor a )
@ -228,13 +228,13 @@ extend Class SWWMHandler
override void WorldThingDestroyed( WorldEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
// for gibber throttling
if ( e.Thing is 'mkBloodDrop' ) blods_realcnt--;
else if ( e.Thing is 'mkFlyingGib' ) meats_realcnt--;
if ( !e.Thing.default.bSHOOTABLE && !e.Thing.default.bMISSILE && !(e.Thing is 'Inventory') && !SWWMUtility.IsBeamProj(e.Thing) )
{
if ( profiling ) worldthingdestroyed_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDESTROYED);
return;
}
// remove from suckables
@ -245,18 +245,18 @@ extend Class SWWMHandler
pos = beams.Find(e.Thing);
if ( pos < beams.Size() )
beams.Delete(pos);
if ( profiling ) worldthingdestroyed_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGDESTROYED);
}
override void WorldThingSpawned( WorldEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
// for gibber throttling
if ( e.Thing is 'mkBloodDrop' ) blods_realcnt++;
else if ( e.Thing is 'mkFlyingGib' ) meats_realcnt++;
if ( !e.Thing || SuppressMultiItem(e) )
{
if ( profiling ) worldthingspawned_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGSPAWNED);
return;
}
IWantDieSpawn(e);
@ -441,6 +441,6 @@ extend Class SWWMHandler
trk.maxhealth = trk.lasthealth = e.Thing.Health;
trk.intp.Reset(trk.lasthealth);
}
if ( profiling ) worldthingspawned_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_WORLDTHINGSPAWNED);
}
}