Ejemplo n.º 1
0
            public JustDisassembly()
            {
                Add(Job.Dry.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20));
                Add(Job.Dry.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp21));

                Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3)));
            }
Ejemplo n.º 2
0
            public JustDisassembly()
            {
                AddJob(Job.Dry.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(CoreRuntime.Core20));
                AddJob(Job.Dry.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(CoreRuntime.Core21));

                AddDiagnoser(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3)));
            }
        public FullProfileConfig()
        {
            var summaryStyle = new SummaryStyle(false, SizeUnit.KB, TimeUnit.Millisecond, true);

            this.SummaryStyle = summaryStyle;

            Add(
                DisassemblyDiagnoser.Create(
                    new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3, printDiff: true)
                    )
                );
            Add(MemoryDiagnoser.Default);
            Add(
                HardwareCounter.BranchInstructions,
                //HardwareCounter.CacheMisses,
                HardwareCounter.BranchMispredictions
                );
            Add(
                Job
                .Core
                .With(Runtime.Core)
                .WithWarmupCount(2)
                .WithIterationCount(10)
                .WithIterationTime(TimeInterval.FromMilliseconds(200))
                .WithLaunchCount(1)
                .With(new GcMode()
            {
                Force = false
            })
                );
        }
Ejemplo n.º 4
0
        public BenchmarkConfig()
        {
            Add(MemoryDiagnoser.Default);
            Add(DisassemblyDiagnoser.Create(
                    new DisassemblyDiagnoserConfig(
                        printAsm: true,
                        printIL: true,
                        printSource: true)));
            Add(AsciiDocExporter.Default);

            Add(Job.Core
                .With(CsProjCoreToolchain.NetCoreApp22)
                .With(new[] { new EnvironmentVariable(JitTieredCompilation, "1") })
                .WithGcServer(true)
                .WithId("CsProjCoreToolchain.NetCoreApp22"));

            Add(Job.Core
                .With(CsProjCoreToolchain.NetCoreApp30)
                .With(new[] { new EnvironmentVariable(JitTieredCompilation, "1") })
                .WithGcServer(true)
                .WithId("CsProjCoreToolchain.NetCoreApp30"));

            Add(Job.Core
                .With(CsProjClassicNetToolchain.Net472)
                .WithGcServer(true)
                .WithId("CsProjClassicNetToolchain.Net472"));
        }
Ejemplo n.º 5
0
        public CoreClrConfig()
        {
            var job = Job.MediumRun.With(
                CustomCoreClrToolchain.CreateBuilder()
                .UseCoreClrNuGet("3.0.0-preview1-26814-05", "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json")
                .UseCoreFxNuGet("4.6.0-preview1-26814-05", "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json")
                .TargetFrameworkMoniker("netcoreapp3.0")
                .DisplayName("Net Core 3.0")
                .RuntimeIdentifier("win-x64")
                .ToToolchain())
                      .WithGcServer(true)
                      .WithIterationCount(23)
                      .WithLaunchCount(1)
                      .WithWarmupCount(5);

            Add(job.With(
                    new List <EnvironmentVariable>()
            {
                new EnvironmentVariable("COMPlus_EnableAVX", "0"),
                new EnvironmentVariable("COMPlus_TieredCompilation", "0")
            }));

            //DefaultConfig.Instance.With()
            Add(DefaultConfig.Instance.GetExporters().ToArray());
            Add(DefaultConfig.Instance.GetLoggers().ToArray());
            Add(DefaultConfig.Instance.GetColumnProviders().ToArray());

            var diagnoser = new DisassemblyDiagnoserConfig(
                printAsm: true, printSource: true, printPrologAndEpilog: true, recursiveDepth: 2);

            Add(DisassemblyDiagnoser.Create(diagnoser));
        }
Ejemplo n.º 6
0
        public DefaultConfig()
        {
            Add(this.GetColumnProviders().ToArray());

            this.UnionRule = ConfigUnionRule.AlwaysUseLocal;

            Add(JitOptimizationsValidator.FailOnError);
            Add(ExecutionValidator.FailOnError);
            Add(TargetMethodColumn.Method);
            Add(new ParamColumn("DataSource"));
            Add(BaselineScaledColumn.Scaled);
            Add(StatisticColumn.Median);
            Add(StatisticColumn.P90);
            Add(MemoryDiagnoser.Default);

            // HACK
            Add(new MetricColumn(MemoryDiagnoser.Default.ProcessResults(new DiagnoserResults(null, 0, new BenchmarkDotNet.Engines.GcStats())).Single(x => x.Descriptor.Id.Equals("Allocated Memory")).Descriptor));
            Add(new InliningDiagnoser());
            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(false, true, true)));

            Add(Job.Dry
                .With(Platform.X64)
                .With(Jit.RyuJit)
                .With(Runtime.Clr)
                .WithGcServer(true)
                .WithWarmupCount(1)
                .WithLaunchCount(1)
                .WithTargetCount(50)
                .WithRemoveOutliers(true)
                .WithAnalyzeLaunchVariance(true)
                .WithEvaluateOverhead(true));

            Add(ConsoleLogger.Default);
            Add(AsciiDocExporter.Default);
        }
Ejemplo n.º 7
0
        public DiagnoserConfig()
        {
            var run = Job.Dry.With(new[] { new EnvironmentVariable("COMPlus_TieredCompilation", "0") });

            Add(run);
            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(true, false, true, true, 5)));
            Add(new InliningDiagnoser());
        }
Ejemplo n.º 8
0
        public DiagnoserConfig()
        {
            var run = Job.Dry.With(new[] { new EnvironmentVariable("COMPlus_TieredCompilation", "0") });

            Add(run);
            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(true, true, true, true, 4)));
            Add(ReturnValueValidator.FailOnError);
            Add(new InliningDiagnoser());
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            var config = DefaultConfig.Instance
                         .With(MemoryDiagnoser.Default)
                         .With(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, recursiveDepth: 3, printDiff: true)));
            var summary = BenchmarkRunner.Run <Point2DManagerStructUseCustomEqualsWithoutBoxing>(config);

            Console.ReadKey();
        }
Ejemplo n.º 10
0
        public Config()
        {
            Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));
            Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20));


            Add(StatisticColumn.Min);
            Add(StatisticColumn.Max);
            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3)));
        }
Ejemplo n.º 11
0
        public void CanDisassembleInlinableBenchmarks(Jit jit, Platform platform, Runtime runtime)
        {
            var disassemblyDiagnoser = (IDisassemblyDiagnoser)DisassemblyDiagnoser.Create(
                new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, printSource: true, recursiveDepth: 3));

            CanExecute <WithInlineable>(CreateConfig(jit, platform, runtime, disassemblyDiagnoser, RunStrategy.Monitoring));

            var disassemblyResult = disassemblyDiagnoser.Results.Values.Single(result => result.Methods.Count(method => method.Name.Contains(nameof(WithInlineable.JustReturn))) == 1);

            Assert.Contains(disassemblyResult.Methods, method => method.Maps.Any(map => map.Instructions.OfType <Asm>().All(asm => asm.TextRepresentation.Contains("ret"))));
        }
        public void DuplicateDiagnosersAreExcludedBasedOnType()
        {
            var mutable = ManualConfig.CreateEmpty();

            mutable.Add(DisassemblyDiagnoser.Create(DisassemblyDiagnoserConfig.All));
            mutable.Add(DisassemblyDiagnoser.Create(DisassemblyDiagnoserConfig.Asm));

            var final = ImmutableConfigBuilder.Create(mutable);

            Assert.Single(final.GetDiagnosers());
        }
        public void CanDisassembleGenericTypes(Jit jit, Platform platform, Runtime runtime)
        {
            var disassemblyDiagnoser = (IDisassemblyDiagnoser)DisassemblyDiagnoser.Create(
                new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, printSource: true, recursiveDepth: 3));

            CanExecute <Generic <int> >(CreateConfig(jit, platform, runtime, disassemblyDiagnoser, RunStrategy.Monitoring));

            var result = disassemblyDiagnoser.Results.Values.Single();

            Assert.Contains(result.Methods, method => method.Maps.Any(map => map.Instructions.OfType <Asm>().Any()));
        }
        public void WhenUserDefinesHardwareCountersAndUsesDisassemblyDiagnoserWeAddInstructionPointerExporter()
        {
            var mutable = ManualConfig.CreateEmpty();

            mutable.Add(HardwareCounter.CacheMisses);
            mutable.Add(DisassemblyDiagnoser.Create(DisassemblyDiagnoserConfig.All));

            var final = ImmutableConfigBuilder.Create(mutable);

            Assert.Single(final.GetDiagnosers().OfType <IHardwareCountersDiagnoser>());
            Assert.Single(final.GetDiagnosers().OfType <IDisassemblyDiagnoser>());
            Assert.Single(final.GetExporters().OfType <InstructionPointerExporter>());
        }
Ejemplo n.º 15
0
        public MultipleJits()
        {
            Add(Job.ShortRun.With(Runtime.Mono).With(Platform.X86));
            Add(Job.ShortRun.With(Runtime.Mono).With(Platform.X64));

            Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X86).With(Runtime.Clr));
            Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X64).With(Runtime.Clr));
            Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));

            Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20));
            Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X86).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20));

            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3)));
        }
        public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, Runtime runtime)
        {
            var disassemblyDiagnoser = (IDisassemblyDiagnoser)DisassemblyDiagnoser.Create(
                new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, printSource: true, recursiveDepth: 3));

            CanExecute <WithCalls>(CreateConfig(jit, platform, runtime, disassemblyDiagnoser, RunStrategy.ColdStart));

            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Benchmark)}(Int32)");
            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Benchmark)}(Boolean)");
            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Static)}()");
            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Instance)}()");
            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Recursive)}()");
            AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Virtual)}()");
        }
        public void VeryShortJobsAreNotSupported()
        {
            var disassemblyDiagnoser = (IDisassemblyDiagnoser)DisassemblyDiagnoser.Create(
                new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, printSource: true, recursiveDepth: 3));

            var config = ManualConfig.CreateEmpty()
                         .With(Job.Dry)
                         .With(DefaultConfig.Instance.GetLoggers().ToArray())
                         .With(DefaultColumnProviders.Instance)
                         .With(disassemblyDiagnoser)
                         .With(new OutputLogger(Output));

            var validationErrors = disassemblyDiagnoser.Validate(BenchmarkConverter.TypeToBenchmarks(typeof(WithCalls), config)).ToArray();

            Assert.Contains(validationErrors, error => error.IsCritical && error.Message == "No Job.Dry support for disassembler. Please use Job.Short");
        }
            public MultipleJits()
            {
                Add(Job.ShortRun.With(new MonoRuntime(name: "Mono x86", customPath: @"C:\Program Files (x86)\Mono\bin\mono.exe")).With(Platform.X86));
                Add(Job.ShortRun.With(new MonoRuntime(name: "Mono x64", customPath: @"C:\Program Files\Mono\bin\mono.exe")).With(Platform.X64));

                Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X86).With(Runtime.Clr));
                Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X64).With(Runtime.Clr));

                Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));

                // RyuJit for .NET Core 2.0
                Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20));

                // RyuJit for .NET Core 2.1
                Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp21));

                Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3, printDiff: true)));
            }
Ejemplo n.º 19
0
            public MultipleJits()
            {
                AddJob(Job.ShortRun.WithPlatform(Platform.X86).WithRuntime(new MonoRuntime(name: "Mono x86", customPath: @"C:\Program Files (x86)\Mono\bin\mono.exe")));
                AddJob(Job.ShortRun.WithPlatform(Platform.X64).WithRuntime(new MonoRuntime(name: "Mono x64", customPath: @"C:\Program Files\Mono\bin\mono.exe")));

                AddJob(Job.ShortRun.WithJit(Jit.LegacyJit).WithPlatform(Platform.X86).WithRuntime(ClrRuntime.Net461));
                AddJob(Job.ShortRun.WithJit(Jit.LegacyJit).WithPlatform(Platform.X64).WithRuntime(ClrRuntime.Net461));

                AddJob(Job.ShortRun.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(ClrRuntime.Net461));

                // RyuJit for .NET Core 2.0
                AddJob(Job.ShortRun.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(CoreRuntime.Core20));

                // RyuJit for .NET Core 2.1
                AddJob(Job.ShortRun.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(CoreRuntime.Core21));

                AddDiagnoser(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printPrologAndEpilog: true, recursiveDepth: 3, printDiff: true)));
            }
Ejemplo n.º 20
0
        public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, Runtime runtime)
        {
            var disassemblyDiagnoser = (IDisassemblyDiagnoser)DisassemblyDiagnoser.Create(
                new DisassemblyDiagnoserConfig(printAsm: true, printIL: true, printSource: true, recursiveDepth: 3));

            CanExecute <WithCalls>(CreateConfig(jit, platform, runtime, disassemblyDiagnoser));

            void AssertDisassembled(IDisassemblyDiagnoser diagnoser, string calledMethodName)
            {
                Assert.True(diagnoser.Results.Single().Value
                            .Methods.Any(method => method.Name.Contains(calledMethodName) && method.Maps.Any(map => map.Instructions.Any())),
                            $"{calledMethodName} is missing");
            }

            AssertDisassembled(disassemblyDiagnoser, nameof(WithCalls.Benchmark));
            AssertDisassembled(disassemblyDiagnoser, nameof(WithCalls.Static));
            AssertDisassembled(disassemblyDiagnoser, nameof(WithCalls.Instance));
            AssertDisassembled(disassemblyDiagnoser, nameof(WithCalls.Recursive));
            AssertDisassembled(disassemblyDiagnoser, nameof(WithCalls.Virtual));
        }
Ejemplo n.º 21
0
        public MultipleRuntimesConfig()
        {
            Add(Job.Default
                .With(CsProjClassicNetToolchain.Net471) // Span NOT supported by Runtime
                .WithId(".NET 4.7.1"));

            //Add(Job.Default
            //    .With(CsProjCoreToolchain.NetCoreApp11) // Span NOT supported by Runtime
            //    .WithId(".NET Core 1.1"));

            /// !!! warning !!! NetCoreApp20 toolchain simply sets TargetFramework = netcoreapp2.0 in generated .csproj
            /// // so you need Visual Studio 2017 Preview 15.3 to be able to run it!
            //Add(Job.Default
            //    .With(CsProjCoreToolchain.NetCoreApp20) // Span SUPPORTED by Runtime
            //    .WithId(".NET Core 2.0"));

            Add(Job.Default
                .With(CsProjCoreToolchain.NetCoreApp21) // Span SUPPORTED by Runtime
                .WithId(".NET Core 2.1"));
            Add(DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig(printAsm: true, printIL: true,
                                                                           printSource: true)));
            Add(MemoryDiagnoser.Default);
        }
 /// <param name="printIL">IL will be printed. False by default.</param>
 /// <param name="printAsm">ASM will be printed. True by default.</param>
 /// <param name="printSource">C# source code will be printed. False by default.</param>
 /// <param name="printPrologAndEpilog">ASM for prolog and epilog will be printed. False by default.</param>
 /// <param name="recursiveDepth">Includes called methods to given level. 1 by default, indexed from 1. To print just benchmark set to 0</param>
 public DisassemblyDiagnoserAttribute(bool printAsm = true, bool printIL = false, bool printSource = false, bool printPrologAndEpilog = false, int recursiveDepth = 1)
 {
     Config = ManualConfig.CreateEmpty().With(
         DisassemblyDiagnoser.Create(
             new DisassemblyDiagnoserConfig(printAsm, printIL, printSource, printPrologAndEpilog, recursiveDepth)));
 }
Ejemplo n.º 23
0
 private static IConfig CreateDefaultConfig() =>
 DefaultConfig
 .Instance
 .With(Job.Core, Job.Clr)
 .With(MemoryDiagnoser.Default)
 .With(DisassemblyDiagnoser.Create(DisassemblyDiagnoserConfig.Asm));
Ejemplo n.º 24
0
 private static IConfig CreateDefaultConfig() =>
 DefaultConfig
 .Instance
 .With(Job.Default.With(CoreRuntime.Core31), Job.Default.With(ClrRuntime.Net48))
 .With(MemoryDiagnoser.Default)
 .With(DisassemblyDiagnoser.Create(DisassemblyDiagnoserConfig.Asm));