BenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19045.2251)
Intel Core i7-8550U CPU 1.80GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
Method | A | B | C | D | Mean | Error | StdDev | Gen0 | Allocated |
Concat | 10 | 20 | 30 | 40 | 100.61 ns | 0.829 ns | 0.775 ns | 0.0669 | 280 B |
Interpolated | 10 | 20 | 30 | 40 | 74.89 ns | 0.903 ns | 0.705 ns | 0.0172 | 72 B |
StringBuilder | 10 | 20 | 30 | 40 | 111.97 ns | 1.277 ns | 1.132 ns | 0.0745 | 312 B |
StringFormat | 10 | 20 | 30 | 40 | 151.44 ns | 1.590 ns | 1.488 ns | 0.0534 | 224 B |
Concat | 10 | 20 | 30 | 123456789 | 119.26 ns | 1.138 ns | 1.065 ns | 0.0725 | 304 B |
Interpolated | 10 | 20 | 30 | 123456789 | 92.58 ns | 0.584 ns | 0.546 ns | 0.0210 | 88 B |
StringBuilder | 10 | 20 | 30 | 123456789 | 125.07 ns | 2.500 ns | 2.879 ns | 0.0782 | 328 B |
StringFormat | 10 | 20 | 30 | 123456789 | 162.81 ns | 3.297 ns | 4.622 ns | 0.0572 | 240 B |