mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: use tables in plugin stats
This commit is contained in:
parent
49793a1f17
commit
efc7e2a136
1 changed files with 172 additions and 149 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Hooking.Internal;
|
using Dalamud.Hooking.Internal;
|
||||||
|
using Dalamud.Interface.Internal.Notifications;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Plugin.Internal;
|
using Dalamud.Plugin.Internal;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
|
|
@ -26,6 +28,9 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
: base("Plugin Statistics###DalamudPluginStatWindow")
|
: base("Plugin Statistics###DalamudPluginStatWindow")
|
||||||
{
|
{
|
||||||
this.RespectCloseHotkey = false;
|
this.RespectCloseHotkey = false;
|
||||||
|
|
||||||
|
this.Size = new Vector2(810, 520);
|
||||||
|
this.SizeCondition = ImGuiCond.FirstUseEver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -50,57 +55,75 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
if (ImGui.Button("Reset"))
|
if (ImGui.Button("Reset"))
|
||||||
{
|
{
|
||||||
foreach (var plugin in pluginManager.InstalledPlugins)
|
foreach (var plugin in pluginManager.InstalledPlugins)
|
||||||
|
{
|
||||||
|
if (plugin.DalamudInterface != null)
|
||||||
{
|
{
|
||||||
plugin.DalamudInterface.UiBuilder.LastDrawTime = -1;
|
plugin.DalamudInterface.UiBuilder.LastDrawTime = -1;
|
||||||
plugin.DalamudInterface.UiBuilder.MaxDrawTime = -1;
|
plugin.DalamudInterface.UiBuilder.MaxDrawTime = -1;
|
||||||
plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Clear();
|
plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.Columns(4);
|
if (ImGui.BeginTable(
|
||||||
ImGui.SetColumnWidth(0, 180f);
|
"##PluginStatsDrawTimes",
|
||||||
ImGui.SetColumnWidth(1, 100f);
|
4,
|
||||||
ImGui.SetColumnWidth(2, 100f);
|
ImGuiTableFlags.RowBg
|
||||||
ImGui.SetColumnWidth(3, 100f);
|
| ImGuiTableFlags.SizingStretchProp
|
||||||
|
| ImGuiTableFlags.Sortable
|
||||||
ImGui.Text("Plugin");
|
| ImGuiTableFlags.Resizable
|
||||||
ImGui.NextColumn();
|
| ImGuiTableFlags.ScrollY
|
||||||
|
| ImGuiTableFlags.Reorderable
|
||||||
ImGui.Text("Last");
|
| ImGuiTableFlags.Hideable))
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Text("Longest");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Text("Average");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Separator();
|
|
||||||
|
|
||||||
foreach (var plugin in pluginManager.InstalledPlugins.Where(plugin => plugin.State == PluginState.Loaded))
|
|
||||||
{
|
{
|
||||||
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
|
ImGui.TableSetupColumn("Plugin");
|
||||||
|
ImGui.TableSetupColumn("Last", ImGuiTableColumnFlags.NoSort); // Changes too fast to sort
|
||||||
|
ImGui.TableSetupColumn("Longest");
|
||||||
|
ImGui.TableSetupColumn("Average");
|
||||||
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
|
var loadedPlugins = pluginManager.InstalledPlugins.Where(plugin => plugin.State == PluginState.Loaded);
|
||||||
|
|
||||||
|
var sortSpecs = ImGui.TableGetSortSpecs();
|
||||||
|
loadedPlugins = sortSpecs.Specs.ColumnIndex switch
|
||||||
|
{
|
||||||
|
0 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? loadedPlugins.OrderBy(plugin => plugin.Name)
|
||||||
|
: loadedPlugins.OrderByDescending(plugin => plugin.Name),
|
||||||
|
2 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? loadedPlugins.OrderBy(plugin => plugin.DalamudInterface?.UiBuilder.MaxDrawTime)
|
||||||
|
: loadedPlugins.OrderByDescending(plugin => plugin.DalamudInterface?.UiBuilder.MaxDrawTime),
|
||||||
|
3 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? loadedPlugins.OrderBy(plugin => plugin.DalamudInterface?.UiBuilder.DrawTimeHistory.Average())
|
||||||
|
: loadedPlugins.OrderByDescending(plugin => plugin.DalamudInterface?.UiBuilder.DrawTimeHistory.Average()),
|
||||||
|
_ => loadedPlugins,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var plugin in loadedPlugins)
|
||||||
|
{
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text(plugin.Manifest.Name);
|
ImGui.Text(plugin.Manifest.Name);
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
|
if (plugin.DalamudInterface != null)
|
||||||
|
{
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{plugin.DalamudInterface.UiBuilder.LastDrawTime / 10000f:F4}ms");
|
ImGui.Text($"{plugin.DalamudInterface.UiBuilder.LastDrawTime / 10000f:F4}ms");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{plugin.DalamudInterface.UiBuilder.MaxDrawTime / 10000f:F4}ms");
|
ImGui.Text($"{plugin.DalamudInterface.UiBuilder.MaxDrawTime / 10000f:F4}ms");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
if (plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Count > 0)
|
ImGui.TableNextColumn();
|
||||||
{
|
ImGui.Text(plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Count > 0
|
||||||
ImGui.Text($"{plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Average() / 10000f:F4}ms");
|
? $"{plugin.DalamudInterface.UiBuilder.DrawTimeHistory.Average() / 10000f:F4}ms"
|
||||||
|
: "-");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui.Text("-");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.NextColumn();
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Columns(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
|
|
@ -123,51 +146,61 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
Framework.StatsHistory.Clear();
|
Framework.StatsHistory.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Columns(4);
|
if (ImGui.BeginTable(
|
||||||
|
"##PluginStatsFrameworkTimes",
|
||||||
ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - 300);
|
4,
|
||||||
ImGui.SetColumnWidth(1, 100f);
|
ImGuiTableFlags.RowBg
|
||||||
ImGui.SetColumnWidth(2, 100f);
|
| ImGuiTableFlags.SizingStretchProp
|
||||||
ImGui.SetColumnWidth(3, 100f);
|
| ImGuiTableFlags.Sortable
|
||||||
|
| ImGuiTableFlags.Resizable
|
||||||
ImGui.Text("Method");
|
| ImGuiTableFlags.ScrollY
|
||||||
ImGui.NextColumn();
|
| ImGuiTableFlags.Reorderable
|
||||||
|
| ImGuiTableFlags.Hideable))
|
||||||
ImGui.Text("Last");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Text("Longest");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Text("Average");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Separator();
|
|
||||||
ImGui.Separator();
|
|
||||||
|
|
||||||
foreach (var handlerHistory in Framework.StatsHistory)
|
|
||||||
{
|
{
|
||||||
if (handlerHistory.Value.Count == 0)
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
continue;
|
ImGui.TableSetupColumn("Method", ImGuiTableColumnFlags.None, 250);
|
||||||
|
ImGui.TableSetupColumn("Last", ImGuiTableColumnFlags.NoSort, 50); // Changes too fast to sort
|
||||||
|
ImGui.TableSetupColumn("Longest", ImGuiTableColumnFlags.None, 50);
|
||||||
|
ImGui.TableSetupColumn("Average", ImGuiTableColumnFlags.None, 50);
|
||||||
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
ImGui.SameLine();
|
var statsHistory = Framework.StatsHistory.ToArray();
|
||||||
|
|
||||||
|
var sortSpecs = ImGui.TableGetSortSpecs();
|
||||||
|
statsHistory = sortSpecs.Specs.ColumnIndex switch
|
||||||
|
{
|
||||||
|
0 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? statsHistory.OrderBy(handler => handler.Key).ToArray()
|
||||||
|
: statsHistory.OrderByDescending(handler => handler.Key).ToArray(),
|
||||||
|
2 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? statsHistory.OrderBy(handler => handler.Value.Max()).ToArray()
|
||||||
|
: statsHistory.OrderByDescending(handler => handler.Value.Max()).ToArray(),
|
||||||
|
3 => sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending
|
||||||
|
? statsHistory.OrderBy(handler => handler.Value.Average()).ToArray()
|
||||||
|
: statsHistory.OrderByDescending(handler => handler.Value.Average()).ToArray(),
|
||||||
|
_ => statsHistory,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var handlerHistory in statsHistory)
|
||||||
|
{
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{handlerHistory.Key}");
|
ImGui.Text($"{handlerHistory.Key}");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{handlerHistory.Value.Last():F4}ms");
|
ImGui.Text($"{handlerHistory.Value.Last():F4}ms");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{handlerHistory.Value.Max():F4}ms");
|
ImGui.Text($"{handlerHistory.Value.Max():F4}ms");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Separator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Columns(0);
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
|
|
@ -177,33 +210,24 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
if (ImGui.BeginTabItem("Hooks"))
|
if (ImGui.BeginTabItem("Hooks"))
|
||||||
{
|
{
|
||||||
ImGui.Columns(4);
|
ImGui.Checkbox("Show Dalamud Hooks", ref this.showDalamudHooks);
|
||||||
|
|
||||||
ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - 330);
|
if (ImGui.BeginTable(
|
||||||
ImGui.SetColumnWidth(1, 180f);
|
"##PluginStatsHooks",
|
||||||
ImGui.SetColumnWidth(2, 100f);
|
4,
|
||||||
ImGui.SetColumnWidth(3, 100f);
|
ImGuiTableFlags.RowBg
|
||||||
|
| ImGuiTableFlags.SizingStretchProp
|
||||||
ImGui.Text("Detour Method");
|
| ImGuiTableFlags.Resizable
|
||||||
ImGui.SameLine();
|
| ImGuiTableFlags.ScrollY
|
||||||
|
| ImGuiTableFlags.Reorderable
|
||||||
ImGui.Text(" ");
|
| ImGuiTableFlags.Hideable))
|
||||||
ImGui.SameLine();
|
{
|
||||||
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
ImGui.Checkbox("Show Dalamud Hooks ###showDalamudHooksCheckbox", ref this.showDalamudHooks);
|
ImGui.TableSetupColumn("Detour Method", ImGuiTableColumnFlags.None, 250);
|
||||||
ImGui.NextColumn();
|
ImGui.TableSetupColumn("Address", ImGuiTableColumnFlags.None, 100);
|
||||||
|
ImGui.TableSetupColumn("Status", ImGuiTableColumnFlags.None, 40);
|
||||||
ImGui.Text("Address");
|
ImGui.TableSetupColumn("Backend", ImGuiTableColumnFlags.None, 40);
|
||||||
ImGui.NextColumn();
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
ImGui.Text("Status");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Text("Backend");
|
|
||||||
ImGui.NextColumn();
|
|
||||||
|
|
||||||
ImGui.Separator();
|
|
||||||
ImGui.Separator();
|
|
||||||
|
|
||||||
foreach (var (guid, trackedHook) in HookManager.TrackedHooks)
|
foreach (var (guid, trackedHook) in HookManager.TrackedHooks)
|
||||||
{
|
{
|
||||||
|
|
@ -215,29 +239,33 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
if (!this.showDalamudHooks && trackedHook.Assembly == Assembly.GetExecutingAssembly())
|
if (!this.showDalamudHooks && trackedHook.Assembly == Assembly.GetExecutingAssembly())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
ImGui.Text($"{trackedHook.Delegate.Target} :: {trackedHook.Delegate.Method.Name}");
|
ImGui.Text($"{trackedHook.Delegate.Target} :: {trackedHook.Delegate.Method.Name}");
|
||||||
ImGui.TextDisabled(trackedHook.Assembly.FullName);
|
ImGui.TextDisabled(trackedHook.Assembly.FullName);
|
||||||
ImGui.NextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (!trackedHook.Hook.IsDisposed)
|
if (!trackedHook.Hook.IsDisposed)
|
||||||
{
|
{
|
||||||
ImGui.Text($"{trackedHook.Hook.Address.ToInt64():X}");
|
if (ImGui.Selectable($"{trackedHook.Hook.Address.ToInt64():X}"))
|
||||||
if (ImGui.IsItemClicked())
|
|
||||||
{
|
{
|
||||||
ImGui.SetClipboardText($"{trackedHook.Hook.Address.ToInt64():X}");
|
ImGui.SetClipboardText($"{trackedHook.Hook.Address.ToInt64():X}");
|
||||||
|
Service<NotificationManager>.Get().AddNotification($"{trackedHook.Hook.Address.ToInt64():X}", "Copied to clipboard", NotificationType.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
var processMemoryOffset = trackedHook.InProcessMemory;
|
var processMemoryOffset = trackedHook.InProcessMemory;
|
||||||
if (processMemoryOffset.HasValue)
|
if (processMemoryOffset.HasValue)
|
||||||
{
|
{
|
||||||
ImGui.Text($"ffxiv_dx11.exe + {processMemoryOffset:X}");
|
if (ImGui.Selectable($"ffxiv_dx11.exe+{processMemoryOffset:X}"))
|
||||||
if (ImGui.IsItemClicked())
|
|
||||||
{
|
{
|
||||||
ImGui.SetClipboardText($"ffxiv_dx11.exe+{processMemoryOffset:X}");
|
ImGui.SetClipboardText($"ffxiv_dx11.exe+{processMemoryOffset:X}");
|
||||||
|
Service<NotificationManager>.Get().AddNotification($"ffxiv_dx11.exe+{processMemoryOffset:X}", "Copied to clipboard", NotificationType.Success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.NextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
if (trackedHook.Hook.IsDisposed)
|
if (trackedHook.Hook.IsDisposed)
|
||||||
{
|
{
|
||||||
|
|
@ -248,23 +276,18 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
ImGui.Text(trackedHook.Hook.IsEnabled ? "Enabled" : "Disabled");
|
ImGui.Text(trackedHook.Hook.IsEnabled ? "Enabled" : "Disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.NextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
ImGui.Text(trackedHook.Hook.BackendName);
|
ImGui.Text(trackedHook.Hook.BackendName);
|
||||||
|
|
||||||
ImGui.NextColumn();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ImGui.Text(ex.Message);
|
ImGui.Text(ex.Message);
|
||||||
ImGui.NextColumn();
|
}
|
||||||
while (ImGui.GetColumnIndex() != 0) ImGui.NextColumn();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Columns();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing())
|
if (ImGui.IsWindowAppearing())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue