Do half the work in GetManagedName by Youssef1313 · Pull Request #15255 · microsoft/vstest (original) (raw)

BenchmarkRunner.Run();

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%