|
10 | 10 |
|
11 | 11 | namespace BenchmarkDotNet.Detectors.Cpu.Linux; |
12 | 12 |
|
| 13 | +#nullable enable |
| 14 | + |
13 | 15 | internal static class LinuxCpuInfoParser |
14 | 16 | { |
15 | 17 | private static class ProcCpu |
@@ -42,27 +44,27 @@ internal static CpuInfo Parse(string cpuInfo, string lscpu) |
42 | 44 | var logicalCores = SectionsHelper.ParseSections(cpuInfo, ':'); |
43 | 45 | foreach (var logicalCore in logicalCores) |
44 | 46 | { |
45 | | - if (logicalCore.TryGetValue(ProcCpu.PhysicalId, out string physicalId) && |
46 | | - logicalCore.TryGetValue(ProcCpu.CpuCores, out string cpuCoresValue) && |
| 47 | + if (logicalCore.TryGetValue(ProcCpu.PhysicalId, out var physicalId) && |
| 48 | + logicalCore.TryGetValue(ProcCpu.CpuCores, out var cpuCoresValue) && |
47 | 49 | int.TryParse(cpuCoresValue, out int cpuCoreCount) && |
48 | 50 | cpuCoreCount > 0) |
49 | 51 | processorsToPhysicalCoreCount[physicalId] = cpuCoreCount; |
50 | 52 |
|
51 | | - if (logicalCore.TryGetValue(ProcCpu.ModelName, out string modelName)) |
| 53 | + if (logicalCore.TryGetValue(ProcCpu.ModelName, out var modelName)) |
52 | 54 | { |
53 | 55 | processorModelNames.Add(modelName); |
54 | 56 | logicalCoreCount++; |
55 | 57 | } |
56 | 58 |
|
57 | | - if (logicalCore.TryGetValue(ProcCpu.MaxFrequency, out string maxCpuFreqValue) && |
| 59 | + if (logicalCore.TryGetValue(ProcCpu.MaxFrequency, out var maxCpuFreqValue) && |
58 | 60 | Frequency.TryParseMHz(maxCpuFreqValue.Replace(',', '.'), out Frequency maxCpuFreq) |
59 | 61 | && maxCpuFreq > 0) |
60 | 62 | { |
61 | 63 | maxFrequency = Math.Max(maxFrequency, maxCpuFreq.ToMHz()); |
62 | 64 | } |
63 | 65 |
|
64 | | - bool nominalFrequencyHasValue = logicalCore.TryGetValue(ProcCpu.NominalFrequency, out string nominalFreqValue); |
65 | | - bool nominalFrequencyBackupHasValue = logicalCore.TryGetValue(ProcCpu.NominalFrequencyBackup, out string nominalFreqBackupValue); |
| 66 | + bool nominalFrequencyHasValue = logicalCore.TryGetValue(ProcCpu.NominalFrequency, out var nominalFreqValue); |
| 67 | + bool nominalFrequencyBackupHasValue = logicalCore.TryGetValue(ProcCpu.NominalFrequencyBackup, out var nominalFreqBackupValue); |
66 | 68 |
|
67 | 69 | double nominalCpuFreq = 0.0; |
68 | 70 | double nominalCpuBackupFreq = 0.0; |
@@ -115,7 +117,7 @@ internal static CpuInfo Parse(string cpuInfo, string lscpu) |
115 | 117 | } |
116 | 118 | } |
117 | 119 |
|
118 | | - string processorName = processorModelNames.Count > 0 ? string.Join(", ", processorModelNames) : null; |
| 120 | + string? processorName = processorModelNames.Count > 0 ? string.Join(", ", processorModelNames) : null; |
119 | 121 | int? physicalProcessorCount = processorsToPhysicalCoreCount.Count > 0 ? processorsToPhysicalCoreCount.Count : null; |
120 | 122 | int? physicalCoreCount = processorsToPhysicalCoreCount.Count > 0 ? processorsToPhysicalCoreCount.Values.Sum() : coresPerSocket; |
121 | 123 |
|
|
0 commit comments