コード例 #1
0
        public override IEnumerable <string> ToFormattedString()
        {
            string vmName = VirtualMachineHypervisor.Value?.Name;

            if (!string.IsNullOrEmpty(vmName))
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}, VM={vmName}");
            }
            else if (RuntimeInformation.IsRunningInContainer)
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value} (container)");
            }
            else
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}");
            }

            yield return(CpuInfoFormatter.Format(CpuInfo.Value));

            var cultureInfo = DefaultCultureInfo.Instance;

            if (HardwareTimerKind != HardwareTimerKind.Unknown)
            {
                yield return($"Frequency={ChronometerFrequency}, Resolution={ChronometerResolution.ToString(cultureInfo)}, Timer={HardwareTimerKind.ToString().ToUpper()}");
            }

            if (RuntimeInformation.IsNetCore && IsDotNetCliInstalled())
            {
                yield return($".NET Core SDK={DotNetSdkVersion.Value}");
            }
        }
コード例 #2
0
        public override IEnumerable <string> ToFormattedString()
        {
            string vmName = VirtualMachineHypervisor.Value?.Name;

            if (!string.IsNullOrEmpty(vmName))
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}, VM={vmName}");
            }
            else if (RuntimeInformation.IsRunningInContainer)
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value} (container)");
            }
            else
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}");
            }

            yield return(CpuInfoFormatter.Format(CpuInfo.Value));

            var cultureInfo = DefaultCultureInfo.Instance;

            if (HardwareTimerKind != HardwareTimerKind.Unknown)
            {
                yield return($"Frequency={ChronometerFrequency}, Resolution={ChronometerResolution.ToString(cultureInfo)}, Timer={HardwareTimerKind.ToString().ToUpper()}");
            }

            if (RuntimeInformation.IsNetCore && IsDotNetCliInstalled())
            {
                // this wonderfull version number contains words like "preview" and ... 5 segments so it can not be parsed by Version.Parse. Example: "5.0.100-preview.8.20362.3"
                if (int.TryParse(new string(DotNetSdkVersion.Value.TrimStart().TakeWhile(char.IsDigit).ToArray()), out int major) && major >= 5)
                {
                    yield return($".NET SDK={DotNetSdkVersion.Value}");
                }
                else
                {
                    yield return($".NET Core SDK={DotNetSdkVersion.Value}");
                }
            }
        }