mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Tui = Terminal.Gui;
|
||||
|
||||
namespace Terminal.Gui.Benchmarks.ConsoleDrivers.EscSeqUtils;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the Set and Append implementations in combination.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A bit misleading because *CursorPosition is called very seldom compared to the other operations
|
||||
/// but they are very similar in performance because they do very similar things.
|
||||
/// </remarks>
|
||||
[MemoryDiagnoser]
|
||||
[BenchmarkCategory (nameof (Tui.EscSeqUtils))]
|
||||
// Hide useless empty column from results.
|
||||
[HideColumns ("stringBuilder")]
|
||||
public class CSI_SetVsAppend
|
||||
{
|
||||
[Benchmark (Baseline = true)]
|
||||
[ArgumentsSource (nameof (StringBuilderSource))]
|
||||
public StringBuilder Set (StringBuilder stringBuilder)
|
||||
{
|
||||
stringBuilder.Append (Tui.EscSeqUtils.CSI_SetBackgroundColorRGB (1, 2, 3));
|
||||
stringBuilder.Append (Tui.EscSeqUtils.CSI_SetForegroundColorRGB (3, 2, 1));
|
||||
stringBuilder.Append (Tui.EscSeqUtils.CSI_SetCursorPosition (4, 2));
|
||||
// Clear to prevent out of memory exception from consecutive iterations.
|
||||
stringBuilder.Clear ();
|
||||
return stringBuilder;
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
[ArgumentsSource (nameof (StringBuilderSource))]
|
||||
public StringBuilder Append (StringBuilder stringBuilder)
|
||||
{
|
||||
Tui.EscSeqUtils.CSI_AppendBackgroundColorRGB (stringBuilder, 1, 2, 3);
|
||||
Tui.EscSeqUtils.CSI_AppendForegroundColorRGB (stringBuilder, 3, 2, 1);
|
||||
Tui.EscSeqUtils.CSI_AppendCursorPosition (stringBuilder, 4, 2);
|
||||
// Clear to prevent out of memory exception from consecutive iterations.
|
||||
stringBuilder.Clear ();
|
||||
return stringBuilder;
|
||||
}
|
||||
|
||||
public static IEnumerable<object> StringBuilderSource ()
|
||||
{
|
||||
return [new StringBuilder ()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Tui = Terminal.Gui;
|
||||
|
||||
namespace Terminal.Gui.Benchmarks.ConsoleDrivers.EscSeqUtils;
|
||||
|
||||
[MemoryDiagnoser]
|
||||
// Hide useless column from results.
|
||||
[HideColumns ("writer")]
|
||||
public class CSI_SetVsWrite
|
||||
{
|
||||
[Benchmark (Baseline = true)]
|
||||
[ArgumentsSource (nameof (TextWriterSource))]
|
||||
public TextWriter Set (TextWriter writer)
|
||||
{
|
||||
writer.Write (Tui.EscSeqUtils.CSI_SetCursorPosition (1, 1));
|
||||
return writer;
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
[ArgumentsSource (nameof (TextWriterSource))]
|
||||
public TextWriter Write (TextWriter writer)
|
||||
{
|
||||
Tui.EscSeqUtils.CSI_WriteCursorPosition (writer, 1, 1);
|
||||
return writer;
|
||||
}
|
||||
|
||||
public static IEnumerable<object> TextWriterSource ()
|
||||
{
|
||||
return [StringWriter.Null];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user