Files
Umbraco-CMS/tests/Umbraco.Tests.Benchmarks/Utf8ToAsciiConverterBaselineBenchmarks.cs
yv01p c5a09233aa perf(strings): add final benchmarks and performance comparison for Utf8ToAsciiConverter
- Create Utf8ToAsciiConverterBenchmarks.cs for new SIMD implementation
- Update baseline benchmarks to use OldUtf8ToAsciiConverter
- Document final benchmark results showing 12-157x speedup for ASCII
- Document 1.3-2.2x speedup for mixed content
- Document 60-100% memory reduction across all scenarios
- Create comprehensive comparison document with analysis

Results:
- Pure ASCII: 12-157x faster with zero allocations (fast-path optimization)
- Mixed content: 1.3-2.2x faster with 73% memory reduction
- New Span API: 95% memory reduction for advanced scenarios
- Worst case (Cyrillic): Similar performance, 60% memory reduction

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-13 03:47:31 +00:00

53 lines
2.1 KiB
C#

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Jobs;
using Umbraco.Cms.Core.Strings;
namespace Umbraco.Tests.Benchmarks;
[MemoryDiagnoser]
[RankColumn]
[StatisticalTestColumn]
public class Utf8ToAsciiConverterBaselineBenchmarks
{
private static readonly string TinyAscii = BenchmarkTextGenerator.GeneratePureAscii(10);
private static readonly string TinyMixed = BenchmarkTextGenerator.GenerateMixed(10);
private static readonly string SmallAscii = BenchmarkTextGenerator.GeneratePureAscii(100);
private static readonly string SmallMixed = BenchmarkTextGenerator.GenerateMixed(100);
private static readonly string MediumAscii = BenchmarkTextGenerator.GeneratePureAscii(1024);
private static readonly string MediumMixed = BenchmarkTextGenerator.GenerateMixed(1024);
private static readonly string LargeAscii = BenchmarkTextGenerator.GeneratePureAscii(100 * 1024);
private static readonly string LargeMixed = BenchmarkTextGenerator.GenerateMixed(100 * 1024);
private static readonly string LargeWorstCase = BenchmarkTextGenerator.GenerateWorstCase(100 * 1024);
[Benchmark]
public string Tiny_Ascii() => OldUtf8ToAsciiConverter.ToAsciiString(TinyAscii);
[Benchmark]
public string Tiny_Mixed() => OldUtf8ToAsciiConverter.ToAsciiString(TinyMixed);
[Benchmark]
public string Small_Ascii() => OldUtf8ToAsciiConverter.ToAsciiString(SmallAscii);
[Benchmark]
public string Small_Mixed() => OldUtf8ToAsciiConverter.ToAsciiString(SmallMixed);
[Benchmark]
public string Medium_Ascii() => OldUtf8ToAsciiConverter.ToAsciiString(MediumAscii);
[Benchmark]
public string Medium_Mixed() => OldUtf8ToAsciiConverter.ToAsciiString(MediumMixed);
[Benchmark]
public string Large_Ascii() => OldUtf8ToAsciiConverter.ToAsciiString(LargeAscii);
[Benchmark]
public string Large_Mixed() => OldUtf8ToAsciiConverter.ToAsciiString(LargeMixed);
[Benchmark]
public string Large_WorstCase() => OldUtf8ToAsciiConverter.ToAsciiString(LargeWorstCase);
[Benchmark]
public char[] CharArray_Medium_Mixed() => OldUtf8ToAsciiConverter.ToAsciiCharArray(MediumMixed);
}