using System.Diagnostics;
public static void Main()
ReadOnlySpan<byte> r = stackalloc byte[] { 52, 48, 48, 55, 48 };
var sw = new Stopwatch();
for (int i=0; i<10000000; i++) result = Test1(r);
Console.WriteLine($"Test1 took {sw.ElapsedMilliseconds}ms {result}");
for (int i=0; i<10000000; i++) result = Test2(r);
Console.WriteLine($"Test2 took {sw.ElapsedMilliseconds}ms {result}");
public static int Test1(ReadOnlySpan<byte> source)
if ((uint)index >= (uint)source.Length)
answer = answer * 10 + c - '0';
public static int Test2(ReadOnlySpan<byte> data)
if (System.Buffers.Text.Utf8Parser.TryParse(data, out int value, out int bytes))