Replies: 2 comments
-
|
I just tried with this on .NET 10: using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Text;
BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Run(args);
[MemoryDiagnoser(false)]
public class Benchmarks
{
private readonly StringBuilder _sb = new (20);
private readonly char[] _buff = new char[12];
[Benchmark]
[Arguments(42)]
public void WithInterpolation(int a) => _sb.Clear().Append($"Foo{a++}").CopyTo(0, _buff, _sb.Length);
[Benchmark]
[Arguments(42)]
public void WithoutInterpolation(int a) => _sb.Clear().Append("Foo").Append(a++).CopyTo(0, _buff, _sb.Length);
}and I don't see any allocation difference:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
My mistake, looks like the IDE tricked me, should have tested from the terminal before. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Given this snippet:
I'd expect the last output to be 0, but it isn't. Using
DefaultInterpolatedStringHandlerI get zero collections:Beta Was this translation helpful? Give feedback.
All reactions