Пример #1
0
 // ReSharper disable once VirtualMemberCallInConstructor
 public FactNotLinuxAttribute(string linuxSkipReason)
 {
     if (RuntimeInformation.IsLinux())
     {
         Skip = linuxSkipReason;
     }
 }
Пример #2
0
        public static bool TrySetAffinity(
            [NotNull] this Process process,
            IntPtr processorAffinity,
            [NotNull] ILogger logger)
        {
            if (process == null)
            {
                throw new ArgumentNullException(nameof(process));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (!RuntimeInformation.IsWindows() && !RuntimeInformation.IsLinux())
            {
                return(false);
            }

            try
            {
                process.ProcessorAffinity = FixAffinity(processorAffinity);
                return(true);
            }
            catch (Exception ex)
            {
                logger.WriteLineError(
                    $"// ! Failed to set up processor affinity 0x{(long)processorAffinity:X} for process {process}. Make sure you have the right permissions. Message: {ex.Message}");
            }

            return(false);
        }
Пример #3
0
 private static CpuInfo Load()
 {
     if (RuntimeInformation.IsLinux())
     {
         string content = ProcessHelper.RunAndReadOutput("cat", "/proc/cpuinfo");
         return(ProcCpuInfoParser.ParseOutput(content));
     }
     return(null);
 }
Пример #4
0
        public static IntPtr?TryGetAffinity([NotNull] this Process process)
        {
            if (process == null)
            {
                throw new ArgumentNullException(nameof(process));
            }

            if (!RuntimeInformation.IsWindows() && !RuntimeInformation.IsLinux())
            {
                return(null);
            }

            try
            {
                return(process.ProcessorAffinity);
            }
            catch (PlatformNotSupportedException)
            {
                return(null);
            }
        }
Пример #5
0
        // This method is as work around because the MonoAOTCompilerTask
        // does not generate files with the right names.
        // In the future it may have an option to write .so/.dylib files,
        // and we can get rid of this method.
        public void RenameSharedLibaries(GenerateResult generateResult, ILogger logger)
        {
            string[] publishDirFiles       = Directory.GetFiles(generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, ".dll.o");
            string   sharedObjectExtension = "";

            if (RuntimeInformation.IsMacOSX())
            {
                sharedObjectExtension = "dylib";
            }
            else if (RuntimeInformation.IsLinux())
            {
                sharedObjectExtension = "so";
            }

            foreach (string fileName in publishDirFiles)
            {
                string newFileName = Path.ChangeExtension(fileName, sharedObjectExtension);

                logger.WriteLine($"RenameSharedLibraries: Moving ${fileName} to {newFileName}");
                File.Move(fileName, newFileName);
            }
        }
 private static bool ShouldUseLinuxDisassembler(BenchmarkCase benchmarkCase)
 => !(benchmarkCase.Job.Environment.Runtime is MonoRuntime) && RuntimeInformation.IsLinux();