Skip to content

Conversation

Youssef1313
Copy link
Member

Hopefully this is going to reduce these:

image image image

I need to benchmark before/after to double check though.

@Evangelink Evangelink merged commit ec1176a into main Aug 13, 2025
6 checks passed
@Evangelink Evangelink deleted the dev/ygerges/perf-managed-helper branch August 13, 2025 05:48
@Youssef1313
Copy link
Member Author

BenchmarkRunner.Run<Bench>();

public class GivenMyTestScenario
{
    public void When_SomeComponent_IsWhatever_Should_DoSomething()
    {

    }
}

[Config(typeof(Config))]
[MemoryDiagnoser]
public class Bench
{
    private class Config : ManualConfig
    {
        public Config()
        {
            var job = Job.Default;
            AddJob(
                job.WithNuGet("Microsoft.TestPlatform.AdapterUtilities", "17.14.1").WithBaseline(true),
                job.WithNuGet("Microsoft.TestPlatform.AdapterUtilities", "18.0.0-preview-25412-05")
            );

            // add the percentage column
            SummaryStyle =
                BenchmarkDotNet.Reports.SummaryStyle.Default
                .WithRatioStyle(BenchmarkDotNet.Columns.RatioStyle.Percentage);
            Options |= ConfigOptions.DisableOptimizationsValidator | ConfigOptions.GenerateMSBuildBinLog;
        }
    }

    private static MethodInfo s_methodInfo = typeof(GivenMyTestScenario).GetMethod(nameof(GivenMyTestScenario.When_SomeComponent_IsWhatever_Should_DoSomething))!;

    [Benchmark]
    public (string?, string?, string?[]?) Benchmark()
    {
        ManagedNameHelper.GetManagedName(s_methodInfo, out var managedName, out var managedType, out var hierarcyValues);
        return (managedName, managedType, hierarcyValues);
    }
}
Method Job NuGetReferences Mean Error StdDev Median Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Benchmark Job-ACPJEB Microsoft.TestPlatform.AdapterUtilities 17.14.1 1,706.4 ns 136.50 ns 402.5 ns 1,527.5 ns baseline 0.1926 0.0038 2.38 KB
Benchmark Job-DRSSHX Microsoft.TestPlatform.AdapterUtilities 18.0.0-preview-25412-05 892.8 ns 74.79 ns 220.5 ns 1,038.4 ns -45% 34.3% 0.0963 0.0010 1.19 KB -50%

@Youssef1313
Copy link
Member Author

45% faster, 50% less memory :)

I think there is still much more to optimize in this helper though :)

This was referenced Oct 2, 2025
This was referenced Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants