Beispiel #1
0
        private static IntPtr FixAffinity(IntPtr processorAffinity)
        {
            int cpuMask = (1 << Environment.ProcessorCount) - 1;

            return(RuntimeInformation.GetCurrentPlatform() == Platform.X64
                ? new IntPtr(processorAffinity.ToInt64() & cpuMask)
                : new IntPtr(processorAffinity.ToInt32() & cpuMask));
        }
        // ReSharper disable once UnusedMemberInSuper.Global
        public virtual IEnumerable <string> ToFormattedString()
        {
            yield return("Benchmark Process Environment Information:");

            yield return($"{RuntimeInfoPrefix}{GetRuntimeInfo()}");

            yield return($"{GcInfoPrefix}{GetGcConcurrentFlag()} {GetGcServerFlag()}");

            yield return($"{HardwareIntrinsicsPrefix}{HardwareIntrinsics.GetFullInfo(RuntimeInformation.GetCurrentPlatform())} {HardwareIntrinsics.GetVectorSize()}");
        }
            public Config()
            {
                var wrongPlatform = RuntimeInformation.GetCurrentPlatform() == Platform.X86
                    ? Platform.X64
                    : Platform.X86;

                Add(Job.MediumRun
                    .WithLaunchCount(1)
                    .With(wrongPlatform)
                    .With(InProcessToolchain.Instance)
                    .WithId("InProcess"));

                Add(InProcessValidator.DontFailOnError);
            }
Beispiel #4
0
        public void CoreRtIsSupported()
        {
            if (RuntimeInformation.GetCurrentPlatform() == Platform.X86) // CoreRT does not support 32bit yet
            {
                return;
            }

            var config = ManualConfig.CreateEmpty()
                         .With(Job.Dry
                               .With(Runtime.CoreRT)
                               .With(CoreRtToolchain.CreateBuilder()
                                     .UseCoreRtNuGet(microsoftDotNetILCompilerVersion: "1.0.0-alpha-26414-01") // we test against specific version to keep this test stable
                                     .ToToolchain()));

            CanExecute <CoreRtBenchmark>(config);
        }
Beispiel #5
0
        public IEnumerable <ValidationError> Validate(ValidationParameters validationParameters)
        {
            var currentPlatform = RuntimeInformation.GetCurrentPlatform();

            if (currentPlatform != Platform.X64 && currentPlatform != Platform.X86)
            {
                yield return(new ValidationError(true, $"{currentPlatform} is not supported (Iced library limitation)"));

                yield break;
            }

            foreach (var benchmark in validationParameters.Benchmarks)
            {
                if (benchmark.Job.Infrastructure.TryGetToolchain(out var toolchain) && toolchain is InProcessNoEmitToolchain)
                {
                    yield return(new ValidationError(true, "InProcessToolchain has no DisassemblyDiagnoser support", benchmark));
                }
        public IEnumerable <ValidationError> Validate(ValidationParameters validationParameters)
        {
            var currentPlatform = RuntimeInformation.GetCurrentPlatform();

            if (currentPlatform != Platform.X64 && currentPlatform != Platform.X86)
            {
                yield return(new ValidationError(true, $"{currentPlatform} is not supported (Iced library limitation)"));

                yield break;
            }

            foreach (var benchmark in validationParameters.Benchmarks)
            {
                if (benchmark.Job.Infrastructure.HasValue(InfrastructureMode.ToolchainCharacteristic) && benchmark.Job.Infrastructure.Toolchain is InProcessNoEmitToolchain)
                {
                    yield return(new ValidationError(true, "InProcessToolchain has no DisassemblyDiagnoser support", benchmark));
                }

                if (ShouldUseLinuxDisassembler(benchmark))
                {
                    var runtime = benchmark.Job.ResolveValue(EnvironmentMode.RuntimeCharacteristic, EnvironmentResolver.Instance);

                    if (runtime.RuntimeMoniker < RuntimeMoniker.NetCoreApp30)
                    {
                        yield return(new ValidationError(true, $"{nameof(DisassemblyDiagnoser)} supports only .NET Core 3.0+", benchmark));
                    }

                    if (ptrace_scope.Value == "2")
                    {
                        yield return(new ValidationError(false, $"ptrace_scope is set to 2, {nameof(DisassemblyDiagnoser)} is going to work only if you run as sudo"));
                    }
                    else if (ptrace_scope.Value == "3")
                    {
                        yield return(new ValidationError(true, $"ptrace_scope is set to 3, {nameof(DisassemblyDiagnoser)} is not going to work"));
                    }
                }
            }
        }
Beispiel #7
0
        public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled()
        {
            if (RuntimeInformation.GetCurrentPlatform() == Platform.X86) // CoreRT does not support 32bit yet
            {
                return;
            }

            // we use CoreRT on purpose because it takes a LOT of time to build it
            // so we can be sure that timeout = 1s should fail!
            var timeout = TimeSpan.FromSeconds(1);

            var config = ManualConfig.CreateEmpty()
                         .With(Job.Dry
                               .With(Runtime.CoreRT)
                               .With(CoreRtToolchain.CreateBuilder()
                                     .UseCoreRtNuGet(microsoftDotNetILCompilerVersion: "1.0.0-alpha-26414-01") // we test against specific version to keep this test stable
                                     .Timeout(timeout)
                                     .ToToolchain()));

            var summary = CanExecute <CoreRtBenchmark>(config, fullValidation: false);

            Assert.All(summary.Reports, report => Assert.False(report.BuildResult.IsBuildSuccess));
            Assert.All(summary.Reports, report => Assert.Contains("The configured timeout", report.BuildResult.BuildException.Message));
        }
Beispiel #8
0
 internal static string ToPresentation(this IntPtr processorAffinity, int processorCount)
 => (RuntimeInformation.GetCurrentPlatform() == Platform.X64
             ? Convert.ToString(processorAffinity.ToInt64(), 2)
             : Convert.ToString(processorAffinity.ToInt32(), 2))
 .PadLeft(processorCount, '0');
 private static string ToPresentation(IntPtr processorAffinity)
 => (RuntimeInformation.GetCurrentPlatform() == Platform.X64
             ? Convert.ToString(processorAffinity.ToInt64(), 2)
             : Convert.ToString(processorAffinity.ToInt32(), 2))
 .PadLeft(Environment.ProcessorCount, '0');