Stop Guessing Which Code Is Faster - BenchmarkDotNet Has Numbers
Your gut feeling about performance is probably wrong. BenchmarkDotNet is the library that turns “I think StringBuilder is faster” into actual nanoseconds, memory allocations, and a pretty table that wins arguments.
It hooks into the .NET runtime, warms up your code, runs it thousands of times, and handles all the statistical noise you’d never think to account for yourself.
Shipped as a NuGet package in 2013, it’s now the de facto standard for .NET micro-benchmarking - even the .NET team uses it internally.
// BenchmarkDotNet gives you this, with proper stats
**sw.Restart();**
var s = “”; for (int i = 0; i < 5000; i++) s += i;
Console.WriteLine($”Plus operator: {sw.ElapsedMilliseconds}ms”);Run it, break it, learn it: https://dotnetfiddle.net/QAP17H


