mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: add TimingEvent, time IM scene init
This commit is contained in:
parent
3ff67c709d
commit
6c877723ce
5 changed files with 169 additions and 134 deletions
|
|
@ -120,7 +120,7 @@ namespace Dalamud
|
||||||
Log.Information("[T1] Game thread continued!");
|
Log.Information("[T1] Game thread continued!");
|
||||||
|
|
||||||
// Initialize FFXIVClientStructs function resolver
|
// Initialize FFXIVClientStructs function resolver
|
||||||
using (Timings.Start("FFXIVClientStructs Resolver Init"))
|
using (Timings.Start("CS Resolver Init"))
|
||||||
{
|
{
|
||||||
FFXIVClientStructs.Resolver.Initialize();
|
FFXIVClientStructs.Resolver.Initialize();
|
||||||
Log.Information("[T1] FFXIVClientStructs initialized!");
|
Log.Information("[T1] FFXIVClientStructs initialized!");
|
||||||
|
|
@ -311,6 +311,7 @@ namespace Dalamud
|
||||||
Troubleshooting.LogTroubleshooting();
|
Troubleshooting.LogTroubleshooting();
|
||||||
|
|
||||||
Log.Information("Dalamud is ready.");
|
Log.Information("Dalamud is ready.");
|
||||||
|
Timings.Event("Dalamud ready");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,8 @@ namespace Dalamud.Interface.Internal
|
||||||
return this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
return this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
||||||
|
|
||||||
if (this.scene == null)
|
if (this.scene == null)
|
||||||
|
{
|
||||||
|
using (Timings.Start("IM Scene Init"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -588,6 +590,7 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
Service<DalamudIME>.Get().Enable();
|
Service<DalamudIME>.Get().Enable();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.address.IsReshade)
|
if (this.address.IsReshade)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
35
Dalamud/Utility/Timing/TimingEvent.cs
Normal file
35
Dalamud/Utility/Timing/TimingEvent.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
namespace Dalamud.Utility.Timing;
|
||||||
|
|
||||||
|
public class TimingEvent
|
||||||
|
{
|
||||||
|
internal TimingEvent(string name)
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
this.StartTime = Timings.Stopwatch.Elapsed.TotalMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the time this timing started.
|
||||||
|
/// </summary>
|
||||||
|
public double StartTime { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the timing.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the member that created this timing.
|
||||||
|
/// </summary>
|
||||||
|
public string? MemberName { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the file name that created this timing.
|
||||||
|
/// </summary>
|
||||||
|
public string? FileName { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the line number that created this timing.
|
||||||
|
/// </summary>
|
||||||
|
public int LineNumber { get; init; }
|
||||||
|
}
|
||||||
|
|
@ -8,16 +8,14 @@ namespace Dalamud.Utility.Timing;
|
||||||
/// Class used for tracking a time interval taken.
|
/// Class used for tracking a time interval taken.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Name} - {Duration}")]
|
[DebuggerDisplay("{Name} - {Duration}")]
|
||||||
public sealed class TimingHandle : IDisposable
|
public sealed class TimingHandle : TimingEvent, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TimingHandle"/> class.
|
/// Initializes a new instance of the <see cref="TimingHandle"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of this timing.</param>
|
/// <param name="name">The name of this timing.</param>
|
||||||
internal TimingHandle(string name)
|
internal TimingHandle(string name) : base(name)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
|
||||||
|
|
||||||
this.Parent = Timings.Current.Value;
|
this.Parent = Timings.Current.Value;
|
||||||
Timings.Current.Value = this;
|
Timings.Current.Value = this;
|
||||||
|
|
||||||
|
|
@ -28,7 +26,6 @@ public sealed class TimingHandle : IDisposable
|
||||||
this.ChildCount++;
|
this.ChildCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.StartTime = Timings.Stopwatch.Elapsed.TotalMilliseconds;
|
|
||||||
this.EndTime = this.StartTime;
|
this.EndTime = this.StartTime;
|
||||||
this.IsMainThread = ThreadSafety.IsMainThread;
|
this.IsMainThread = ThreadSafety.IsMainThread;
|
||||||
|
|
||||||
|
|
@ -41,11 +38,6 @@ public sealed class TimingHandle : IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the time this timing started.
|
|
||||||
/// </summary>
|
|
||||||
public double StartTime { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the time this timing ended.
|
/// Gets the time this timing ended.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -81,26 +73,6 @@ public sealed class TimingHandle : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public uint Depth { get; private set; }
|
public uint Depth { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the name of the timing.
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the member that created this timing.
|
|
||||||
/// </summary>
|
|
||||||
public string? MemberName { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the file name that created this timing.
|
|
||||||
/// </summary>
|
|
||||||
public string? FileName { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the line number that created this timing.
|
|
||||||
/// </summary>
|
|
||||||
public int LineNumber { get; init; }
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ public static class Timings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static readonly List<TimingHandle> ActiveTimings = new();
|
internal static readonly List<TimingHandle> ActiveTimings = new();
|
||||||
|
|
||||||
|
internal static readonly List<TimingEvent> Events = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current active timing entry.
|
/// Current active timing entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -48,4 +50,26 @@ public static class Timings
|
||||||
LineNumber = sourceLineNumber,
|
LineNumber = sourceLineNumber,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Record a one-time event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the timing.</param>
|
||||||
|
/// <param name="memberName">Name of the calling member.</param>
|
||||||
|
/// <param name="sourceFilePath">Name of the calling file.</param>
|
||||||
|
/// <param name="sourceLineNumber">Name of the calling line number.</param>
|
||||||
|
/// <returns>Disposable that stops the timing once disposed.</returns>
|
||||||
|
public static void Event(string name, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "",
|
||||||
|
[CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
lock (Events)
|
||||||
|
{
|
||||||
|
Events.Add(new TimingEvent(name)
|
||||||
|
{
|
||||||
|
MemberName = memberName,
|
||||||
|
FileName = sourceFilePath,
|
||||||
|
LineNumber = sourceLineNumber,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue