public static void ProcessLimitSet(this ILogger logger, string limit, object value) { string str; if (value is IntPtr ip && limit == nameof(IsolationLimits.AffinityMask)) { str = ProcessAffinity.ToString(ip, Environment.ProcessorCount); }
public void TryParse(string str, int maximumProcessorCount, bool concise, bool result) { bool actual = ProcessAffinity.TryParse(str, out var affinity); Assert.Equal(result, actual); if (result) { Assert.Equal(Normalize(str), ProcessAffinity.ToString(affinity, maximumProcessorCount, false, concise)?.Trim()); } else { Assert.Equal(IntPtr.Zero, affinity); } }
public void Parse(string str, int maximumProcessorCount, bool concise) { Assert.Equal(Normalize(str), ProcessAffinity.ToString(ProcessAffinity.Parse(str), maximumProcessorCount, false, concise)?.Trim()); }
public void Calculate(int processorCount, int maximumProcessorCount, string expectedResult) { Assert.Equal(expectedResult, ProcessAffinity.ToString( ProcessAffinity.Calculate(processorCount, maximumProcessorCount), maximumProcessorCount, false, false)); }
public static void FormatLimits(this IJobObjectInformation o, Action <string> output, CultureInfo culture) { if (o == null) { throw new ArgumentNullException(nameof(o)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } if (o.KillProcessesOnJobClose) { output(string.Format(culture, "KillProcessesOnJobClose {0,26}", o.KillProcessesOnJobClose)); } if (o.CpuRateLimit > 0) { output(string.Format(culture, "CpuRateLimit {0,25}%", o.CpuRateLimit)); } if (o.ProcessMemoryLimit > 0) { output(string.Format(culture, "ProcessMemoryLimit {0,26}", Utils.FormatBytes(o.ProcessMemoryLimit))); } if (o.WorkingSetLimit != JobMinMaxValue.Empty) { output(string.Format(culture, "WorkingSetLimit {0,26}", Utils.FormatBytes(o.WorkingSetLimit.Minimum) + "/" + Utils.FormatBytes(o.WorkingSetLimit.Maximum))); } if (o.JobMemoryLimit > 0) { output(string.Format(culture, "JobMemoryLimit {0,26}", Utils.FormatBytes(o.JobMemoryLimit))); } if (o.AllowChildProcessesBreakaway) { output(string.Format(culture, "AllowChildProcessesBreakaway {0,26}", o.AllowChildProcessesBreakaway)); } if (o.AlwaysBreakawayChildProcesses) { output(string.Format(culture, "AlwaysBreakawayChildProcesses {0,26}", o.AlwaysBreakawayChildProcesses)); } if (o.ActiveProcessesLimit > 0) { output(string.Format(culture, "ActiveProcessesLimit {0,26}", o.ActiveProcessesLimit)); } if (o.DieOnUnhandledException) { output(string.Format(culture, "DieOnUnhandledException {0,26}", o.DieOnUnhandledException)); } if (o.JobUserTimeLimit != TimeSpan.Zero) { output(string.Format(culture, "JobUserTimeLimit {0,26}", o.JobUserTimeLimit)); } if (o.ProcessUserTimeLimit != TimeSpan.Zero) { output(string.Format(culture, "ProcessUserTimeLimit {0,26}", o.ProcessUserTimeLimit)); } if (o.PriorityClass > 0) { output(string.Format(culture, "PriorityClass {0,26}", o.PriorityClass)); } if (o.SchedulingClass > 0) { output(string.Format(culture, "SchedulingClass {0,26}", o.SchedulingClass)); } if (o.ProcessorAffinity != IntPtr.Zero) { output(string.Format(culture, "ProcessorAffinity {0,26}", ProcessAffinity.ToString(o.ProcessorAffinity))); } if (o.Weight > 0) { output(string.Format(culture, "Weight {0,26}", o.Weight)); } if (o.RateMinMaxLimit != JobMinMaxValue.Empty) { output(string.Format(culture, "RateMinMaxLimit {0,26}", o.RateMinMaxLimit)); } }