mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 16:27:55 +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
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Text;
|
|
using BenchmarkDotNet.Attributes;
|
|
using Tui = Terminal.Gui;
|
|
|
|
namespace Terminal.Gui.Benchmarks.Text.RuneExtensions;
|
|
|
|
/// <summary>
|
|
/// Benchmarks for <see cref="Tui.RuneExtensions.EncodeSurrogatePair"/> performance fine-tuning.
|
|
/// </summary>
|
|
[MemoryDiagnoser]
|
|
[BenchmarkCategory (nameof (Tui.RuneExtensions))]
|
|
public class EncodeSurrogatePair
|
|
{
|
|
/// <summary>
|
|
/// Benchmark for current implementation.
|
|
/// </summary>
|
|
[Benchmark (Baseline = true)]
|
|
[ArgumentsSource (nameof (DataSource))]
|
|
public Rune Current (char highSurrogate, char lowSurrogate)
|
|
{
|
|
_ = Tui.RuneExtensions.EncodeSurrogatePair (highSurrogate, lowSurrogate, out Rune rune);
|
|
return rune;
|
|
}
|
|
|
|
public static IEnumerable<object []> DataSource ()
|
|
{
|
|
string[] runeStrings = ["🍕", "🧠", "🌹"];
|
|
foreach (string symbol in runeStrings)
|
|
{
|
|
if (symbol is [char high, char low])
|
|
{
|
|
yield return [high, low];
|
|
}
|
|
}
|
|
}
|
|
}
|