Skip to content

Instantly share code, notes, and snippets.

@davidwengier
Last active November 24, 2019 22:19
Show Gist options
  • Save davidwengier/9a261691ef5a6f2880b088a8e11c15b2 to your computer and use it in GitHub Desktop.
Save davidwengier/9a261691ef5a6f2880b088a8e11c15b2 to your computer and use it in GitHub Desktop.
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