mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 12:23:39 +01:00
102 lines
2.8 KiB
C#
102 lines
2.8 KiB
C#
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Configuration.Internal;
|
|
using Dalamud.Storage;
|
|
using Serilog;
|
|
|
|
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
|
|
|
/// <summary>
|
|
/// Widget for displaying configuration info.
|
|
/// </summary>
|
|
internal class VfsWidget : IDataWindowWidget
|
|
{
|
|
private int numBytes = 1024;
|
|
private int reps = 1;
|
|
|
|
/// <inheritdoc/>
|
|
public string[]? CommandShortcuts { get; init; } = { "vfs" };
|
|
|
|
/// <inheritdoc/>
|
|
public string DisplayName { get; init; } = "VFS Performance";
|
|
|
|
/// <inheritdoc/>
|
|
public bool Ready { get; set; }
|
|
|
|
/// <inheritdoc/>
|
|
public void Load()
|
|
{
|
|
this.Ready = true;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Draw()
|
|
{
|
|
var service = Service<ReliableFileStorage>.Get();
|
|
var dalamud = Service<Dalamud>.Get();
|
|
|
|
ImGui.InputInt("Num bytes"u8, ref this.numBytes);
|
|
ImGui.InputInt("Reps"u8, ref this.reps);
|
|
|
|
var path = Path.Combine(dalamud.StartInfo.WorkingDirectory!, "test.bin");
|
|
|
|
if (ImGui.Button("Write"u8))
|
|
{
|
|
Log.Information("=== WRITING ===");
|
|
var data = new byte[this.numBytes];
|
|
var stopwatch = new Stopwatch();
|
|
var acc = 0L;
|
|
|
|
for (var i = 0; i < this.reps; i++)
|
|
{
|
|
stopwatch.Restart();
|
|
service.WriteAllBytes(path, data);
|
|
stopwatch.Stop();
|
|
acc += stopwatch.ElapsedMilliseconds;
|
|
Log.Information("Turn {Turn} took {Ms}ms", i, stopwatch.ElapsedMilliseconds);
|
|
}
|
|
|
|
Log.Information("Took {Ms}ms in total", acc);
|
|
}
|
|
|
|
if (ImGui.Button("Read"u8))
|
|
{
|
|
Log.Information("=== READING ===");
|
|
var stopwatch = new Stopwatch();
|
|
var acc = 0L;
|
|
|
|
for (var i = 0; i < this.reps; i++)
|
|
{
|
|
stopwatch.Restart();
|
|
service.ReadAllBytes(path);
|
|
stopwatch.Stop();
|
|
acc += stopwatch.ElapsedMilliseconds;
|
|
Log.Information("Turn {Turn} took {Ms}ms", i, stopwatch.ElapsedMilliseconds);
|
|
}
|
|
|
|
Log.Information("Took {Ms}ms in total", acc);
|
|
}
|
|
|
|
if (ImGui.Button("Test Config"u8))
|
|
{
|
|
var config = Service<DalamudConfiguration>.Get();
|
|
|
|
Log.Information("=== READING ===");
|
|
var stopwatch = new Stopwatch();
|
|
var acc = 0L;
|
|
|
|
for (var i = 0; i < this.reps; i++)
|
|
{
|
|
stopwatch.Restart();
|
|
config.ForceSave();
|
|
stopwatch.Stop();
|
|
acc += stopwatch.ElapsedMilliseconds;
|
|
Log.Information("Turn {Turn} took {Ms}ms", i, stopwatch.ElapsedMilliseconds);
|
|
}
|
|
|
|
Log.Information("Took {Ms}ms in total", acc);
|
|
}
|
|
}
|
|
}
|