Timing test.

This commit is contained in:
Ottermandias 2023-01-03 21:55:39 +01:00
parent 6bc0b77ad3
commit f2997102c7
15 changed files with 220 additions and 59 deletions

View file

@ -126,6 +126,7 @@ public unsafe partial class PathResolver
private ulong LoadTimelineResourcesDetour( IntPtr timeline )
{
TimingManager.StartTimer( TimingType.TimelineResources );
ulong ret;
var old = _animationLoadData;
try
@ -152,6 +153,7 @@ public unsafe partial class PathResolver
_animationLoadData = old;
TimingManager.StopTimer( TimingType.TimelineResources );
return ret;
}
@ -246,6 +248,7 @@ public unsafe partial class PathResolver
private IntPtr LoadCharacterVfxDetour( byte* vfxPath, VfxParams* vfxParams, byte unk1, byte unk2, float unk3, int unk4 )
{
TimingManager.StartTimer( TimingType.LoadCharacterVfx );
var last = _animationLoadData;
if( vfxParams != null && vfxParams->GameObjectId != unchecked( ( uint )-1 ) )
{
@ -264,7 +267,6 @@ public unsafe partial class PathResolver
{
_animationLoadData = ResolveData.Invalid;
}
var ret = _loadCharacterVfxHook.Original( vfxPath, vfxParams, unk1, unk2, unk3, unk4 );
#if DEBUG
var path = new ByteString( vfxPath );
@ -272,6 +274,7 @@ public unsafe partial class PathResolver
$"Load Character VFX: {path} {vfxParams->GameObjectId:X} {vfxParams->TargetCount} {unk1} {unk2} {unk3} {unk4} -> {ret:X} {_animationLoadData.ModCollection.Name} {_animationLoadData.AssociatedGameObject} {last.ModCollection.Name} {last.AssociatedGameObject}" );
#endif
_animationLoadData = last;
TimingManager.StopTimer( TimingType.LoadCharacterVfx );
return ret;
}
@ -282,6 +285,7 @@ public unsafe partial class PathResolver
private IntPtr LoadAreaVfxDetour( uint vfxId, float* pos, GameObject* caster, float unk1, float unk2, byte unk3 )
{
TimingManager.StartTimer( TimingType.LoadAreaVfx );
var last = _animationLoadData;
if( caster != null )
{
@ -298,6 +302,7 @@ public unsafe partial class PathResolver
$"Load Area VFX: {vfxId}, {pos[ 0 ]} {pos[ 1 ]} {pos[ 2 ]} {( caster != null ? new ByteString( caster->GetName() ).ToString() : "Unknown" )} {unk1} {unk2} {unk3} -> {ret:X} {_animationLoadData.ModCollection.Name} {_animationLoadData.AssociatedGameObject} {last.ModCollection.Name} {last.AssociatedGameObject}" );
#endif
_animationLoadData = last;
TimingManager.StopTimer( TimingType.LoadAreaVfx );
return ret;
}

View file

@ -138,6 +138,7 @@ public unsafe partial class PathResolver
private IntPtr CharacterBaseCreateDetour( uint a, IntPtr b, IntPtr c, byte d )
{
TimingManager.StartTimer( TimingType.CharacterBaseCreate );
var meta = DisposableContainer.Empty;
if( LastGameObject != null )
{
@ -170,6 +171,7 @@ public unsafe partial class PathResolver
{
meta.Dispose();
}
TimingManager.StopTimer( TimingType.CharacterBaseCreate );
return ret;
}

View file

@ -24,6 +24,7 @@ public unsafe partial class PathResolver
return new ResolveData( Penumbra.CollectionManager.Default );
}
TimingManager.StartTimer( TimingType.IdentifyCollection );
try
{
if( useCache && IdentifiedCache.TryGetValue( gameObject, out var data ) )
@ -60,6 +61,7 @@ public unsafe partial class PathResolver
?? CollectionByAttributes( gameObject )
?? CheckOwnedCollection( identifier, owner )
?? Penumbra.CollectionManager.Default;
return IdentifiedCache.Set( collection, identifier, gameObject );
}
catch( Exception e )
@ -67,24 +69,35 @@ public unsafe partial class PathResolver
Penumbra.Log.Error( $"Error identifying collection:\n{e}" );
return Penumbra.CollectionManager.Default.ToResolveData( gameObject );
}
finally
{
TimingManager.StopTimer( TimingType.IdentifyCollection );
}
}
// Get the collection applying to the current player character
// or the default collection if no player exists.
public static ModCollection PlayerCollection()
{
var gameObject = ( GameObject* )Dalamud.Objects.GetObjectAddress( 0 );
TimingManager.StartTimer( TimingType.IdentifyCollection );
var gameObject = ( GameObject* )Dalamud.Objects.GetObjectAddress( 0 );
ModCollection ret;
if( gameObject == null )
{
return Penumbra.CollectionManager.ByType( CollectionType.Yourself )
ret = Penumbra.CollectionManager.ByType( CollectionType.Yourself )
?? Penumbra.CollectionManager.Default;
}
else
{
var player = Penumbra.Actors.GetCurrentPlayer();
return CollectionByIdentifier( player )
?? CheckYourself( player, gameObject )
?? CollectionByAttributes( gameObject )
?? Penumbra.CollectionManager.Default;
var player = Penumbra.Actors.GetCurrentPlayer();
ret = CollectionByIdentifier( player )
?? CheckYourself( player, gameObject )
?? CollectionByAttributes( gameObject )
?? Penumbra.CollectionManager.Default;
}
TimingManager.StopTimer( TimingType.IdentifyCollection );
return ret;
}
// Check both temporary and permanent character collections. Temporary first.

View file

@ -95,6 +95,7 @@ public unsafe partial class PathResolver
// Special handling for paths so that we do not store non-owned temporary strings in the dictionary.
public void SetCollection( IntPtr gameObject, ByteString path, ModCollection collection )
{
TimingManager.StartTimer( TimingType.SetPathCollection );
if( _pathCollections.ContainsKey( path ) || path.IsOwned )
{
_pathCollections[ path ] = collection.ToResolveData( gameObject );
@ -103,6 +104,7 @@ public unsafe partial class PathResolver
{
_pathCollections[ path.Clone() ] = collection.ToResolveData( gameObject );
}
TimingManager.StopTimer( TimingType.SetPathCollection );
}
}
}

View file

@ -113,7 +113,9 @@ public unsafe partial class PathResolver
case ResourceType.Avfx:
if( handle->FileSize == 0 )
{
TimingManager.StartTimer( TimingType.AddSubfile );
_subFileCollection[ ( IntPtr )handle ] = resolveData;
TimingManager.StopTimer( TimingType.AddSubfile );
}
break;
@ -126,7 +128,9 @@ public unsafe partial class PathResolver
{
case ResourceType.Mtrl:
case ResourceType.Avfx:
TimingManager.StartTimer( TimingType.AddSubfile );
_subFileCollection.TryRemove( ( IntPtr )handle, out _ );
TimingManager.StopTimer( TimingType.AddSubfile );
break;
}
}

View file

@ -48,6 +48,7 @@ public partial class PathResolver : IDisposable
// The modified resolver that handles game path resolving.
private bool CharacterResolver( Utf8GamePath gamePath, ResourceCategory _1, ResourceType type, int _2, out (FullPath?, ResolveData) data )
{
TimingManager.StartTimer( TimingType.CharacterResolver );
// Check if the path was marked for a specific collection,
// or if it is a file loaded by a material, and if we are currently in a material load,
// or if it is a face decal path and the current mod collection is set.
@ -71,6 +72,7 @@ public partial class PathResolver : IDisposable
// We also need to handle defaulted materials against a non-default collection.
var path = resolved == null ? gamePath.Path : resolved.Value.InternalName;
SubfileHelper.HandleCollection( resolveData, path, nonDefault, type, resolved, out data );
TimingManager.StopTimer( TimingType.CharacterResolver );
return true;
}