Ejemplo n.º 1
0
        public override IEnumerable <string> ToFormattedString()
        {
            string vmName = VirtualMachineHypervisor.Value?.Name;

            if (vmName == null)
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}");
            }
            else
            {
                yield return($"{BenchmarkDotNetCaption}=v{BenchmarkDotNetVersion}, OS={OsVersion.Value}, VM={vmName}");
            }

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

            if (HardwareTimerKind != HardwareTimerKind.Unknown)
            {
                yield return($"Frequency={ChronometerFrequency}, Resolution={ChronometerResolution}, Timer={HardwareTimerKind.ToString().ToUpper()}");
            }
#if !CLASSIC
            if (IsDotNetCliInstalled())
            {
                yield return($".NET Core SDK={DotNetSdkVersion.Value}");
            }
#endif
        }
Ejemplo n.º 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())
            {
                yield return($".NET Core SDK={DotNetSdkVersion.Value}");
            }
        }
Ejemplo n.º 3
0
        public void FormatTest()
        {
            var captions = new StringBuilder();

            foreach (var processorName in new[] { null, "", "Intel" })
            {
                foreach (var physicalProcessorCount in new int?[] { null, 0, 1, 2 })
                {
                    foreach (var physicalCoreCount in new int?[] { null, 0, 1, 2 })
                    {
                        foreach (var logicalCoreCount in new int?[] { null, 0, 1, 2 })
                        {
                            var mockCpuInfo = new CpuInfo(processorName, physicalProcessorCount, physicalCoreCount, logicalCoreCount, null, null, null);
                            captions.AppendLine(CpuInfoFormatter.Format(mockCpuInfo));
                        }
                    }
                }
            }

            Approvals.Verify(captions.ToString());
        }
        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}");
                }
            }
        }