Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using BenchmarkDotNet.Attributes;
namespace BenchmarkCore
{
[MemoryDiagnoser]
public class InterpolatedStrings
{
[Benchmark]
public string IntToString()
{
return $"b{1.ToString()}b";
}
[Benchmark]
public string Int()
{
return $"a{1}a";
}
}
}
      Method |      Mean |    Error |    StdDev |    Median |  Gen 0 | Allocated |
------------ |----------:|---------:|----------:|----------:|-------:|----------:|
 IntToString |  56.59 ns | 2.616 ns |  7.713 ns |  53.25 ns | 0.0111 |      64 B |
         Int | 147.84 ns | 5.335 ns | 15.730 ns | 144.41 ns | 0.0095 |      56 B |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment