-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'condition-furcation' into main
- Loading branch information
Showing
20 changed files
with
552 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Dalamud.Interface.Utility.Raii; | ||
using ImPlotNET; | ||
using System; | ||
using System.Numerics; | ||
|
||
namespace Craftimizer.Plugin; | ||
|
||
public static class ImRaii2 | ||
{ | ||
private struct EndUnconditionally : ImRaii.IEndObject, IDisposable | ||
{ | ||
private Action EndAction { get; } | ||
|
||
public bool Success { get; } | ||
|
||
public bool Disposed { get; private set; } | ||
|
||
public EndUnconditionally(Action endAction, bool success) | ||
{ | ||
EndAction = endAction; | ||
Success = success; | ||
Disposed = false; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (!Disposed) | ||
{ | ||
EndAction(); | ||
Disposed = true; | ||
} | ||
} | ||
} | ||
|
||
private struct EndConditionally : ImRaii.IEndObject, IDisposable | ||
{ | ||
public bool Success { get; } | ||
|
||
public bool Disposed { get; private set; } | ||
|
||
private Action EndAction { get; } | ||
|
||
public EndConditionally(Action endAction, bool success) | ||
{ | ||
EndAction = endAction; | ||
Success = success; | ||
Disposed = false; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (!Disposed) | ||
{ | ||
if (Success) | ||
{ | ||
EndAction(); | ||
} | ||
|
||
Disposed = true; | ||
} | ||
} | ||
} | ||
|
||
public static ImRaii.IEndObject GroupPanel(string name, float width, out float internalWidth) | ||
{ | ||
internalWidth = ImGuiUtils.BeginGroupPanel(name, width); | ||
return new EndUnconditionally(ImGuiUtils.EndGroupPanel, true); | ||
} | ||
|
||
public static ImRaii.IEndObject Plot(string title_id, Vector2 size, ImPlotFlags flags) | ||
{ | ||
return new EndConditionally(new Action(ImPlot.EndPlot), ImPlot.BeginPlot(title_id, size, flags)); | ||
} | ||
|
||
public static ImRaii.IEndObject PushStyle(ImPlotStyleVar idx, Vector2 val) | ||
{ | ||
ImPlot.PushStyleVar(idx, val); | ||
return new EndUnconditionally(ImPlot.PopStyleVar, true); | ||
} | ||
|
||
public static ImRaii.IEndObject PushStyle(ImPlotStyleVar idx, float val) | ||
{ | ||
ImPlot.PushStyleVar(idx, val); | ||
return new EndUnconditionally(ImPlot.PopStyleVar, true); | ||
} | ||
|
||
public static ImRaii.IEndObject PushColor(ImPlotCol idx, Vector4 col) | ||
{ | ||
ImPlot.PushStyleColor(idx, col); | ||
return new EndUnconditionally(ImPlot.PopStyleColor, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
12359ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
Craftimizer.Benchmark.Bench.Solve(State: 5372D31C98FA4C357F54029912394B0F5ECBE94AEC9D12C1C2B7F453C62ACD2F, Config: E1C895829E5BB1533C41D3C71AD65B6B3E1A60B5EE2D35A845744C251E71EFA5)
1787148186.6666667
ns (± 29859865.600258883
)Craftimizer.Benchmark.Bench.Solve(State: 5372D31C98FA4C357F54029912394B0F5ECBE94AEC9D12C1C2B7F453C62ACD2F, Config: E1C895829E5BB1533C41D3C71AD65B6B3E1A60B5EE2D35A845744C251E71EFA5)
1421138653.3333333
ns (± 20497906.774207342
)Craftimizer.Benchmark.Bench.Solve(State: 99B0F1AD46A18B4D8262F9BA75ABE23507217C2F20FBF895A49282DDFEF50190, Config: E1C895829E5BB1533C41D3C71AD65B6B3E1A60B5EE2D35A845744C251E71EFA5)
1720543280
ns (± 10731279.112429103
)Craftimizer.Benchmark.Bench.Solve(State: 99B0F1AD46A18B4D8262F9BA75ABE23507217C2F20FBF895A49282DDFEF50190, Config: E1C895829E5BB1533C41D3C71AD65B6B3E1A60B5EE2D35A845744C251E71EFA5)
1398625128.5714285
ns (± 7012174.725809015
)This comment was automatically generated by workflow using github-action-benchmark.