mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-15 04:17:43 +01:00
Stat tracking for Framework Updates
to help developers see if their plugin is slowing the game down or not removing their framework update events.
This commit is contained in:
parent
f8e5728985
commit
f1f7803434
2 changed files with 97 additions and 8 deletions
|
|
@ -1,14 +1,15 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Internal;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface {
|
||||
class DalamudPluginStatWindow : IDisposable {
|
||||
internal class DalamudPluginStatWindow : IDisposable {
|
||||
|
||||
private PluginManager pm;
|
||||
public DalamudPluginStatWindow(PluginManager pm) {
|
||||
this.pm = pm;
|
||||
private readonly PluginManager pluginManager;
|
||||
public DalamudPluginStatWindow(PluginManager pluginManager) {
|
||||
this.pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
public bool Draw() {
|
||||
|
|
@ -29,7 +30,7 @@ namespace Dalamud.Interface {
|
|||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Reset")) {
|
||||
foreach (var a in this.pm.Plugins) {
|
||||
foreach (var a in this.pluginManager.Plugins) {
|
||||
a.PluginInterface.UiBuilder.lastDrawTime = -1;
|
||||
a.PluginInterface.UiBuilder.maxDrawTime = -1;
|
||||
a.PluginInterface.UiBuilder.drawTimeHistory.Clear();
|
||||
|
|
@ -51,7 +52,7 @@ namespace Dalamud.Interface {
|
|||
ImGui.Text("Average");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Separator();
|
||||
foreach (var a in this.pm.Plugins) {
|
||||
foreach (var a in this.pluginManager.Plugins) {
|
||||
ImGui.Text(a.Definition.Name);
|
||||
ImGui.NextColumn();
|
||||
ImGui.Text($"{a.PluginInterface.UiBuilder.lastDrawTime/10000f:F4}ms");
|
||||
|
|
@ -69,6 +70,59 @@ namespace Dalamud.Interface {
|
|||
ImGui.Columns(1);
|
||||
|
||||
}
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Framework times")) {
|
||||
|
||||
var doStats = Framework.StatsEnabled;
|
||||
|
||||
if (ImGui.Checkbox("Enable Framework Update Tracking", ref doStats)) {
|
||||
Framework.StatsEnabled = doStats;
|
||||
}
|
||||
|
||||
if (doStats) {
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Reset")) {
|
||||
Framework.StatsHistory.Clear();
|
||||
}
|
||||
|
||||
ImGui.Columns(4);
|
||||
ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionWidth() - 300);
|
||||
ImGui.SetColumnWidth(1, 100f);
|
||||
ImGui.SetColumnWidth(2, 100f);
|
||||
ImGui.SetColumnWidth(3, 100f);
|
||||
ImGui.Text("Method");
|
||||
ImGui.NextColumn();
|
||||
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) continue;
|
||||
ImGui.SameLine();
|
||||
ImGui.Text($"{handlerHistory.Key}");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Text($"{handlerHistory.Value.Last():F4}ms");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Text($"{handlerHistory.Value.Max():F4}ms");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Separator();
|
||||
}
|
||||
ImGui.Columns(0);
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue