Skip to content

Commit c9f9cf9

Browse files
authored
Basic changes to match defined code style. (#3029)
1 parent a39cc80 commit c9f9cf9

20 files changed

+105
-105
lines changed

src/tools/Reporting/Reporting/Reporter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void Init()
5959
Queue = environment.GetEnvironmentVariable("PERFLAB_QUEUE"),
6060
WorkItemName = environment.GetEnvironmentVariable("HELIX_WORKITEM_FRIENDLYNAME"),
6161
};
62-
Boolean.TryParse(environment.GetEnvironmentVariable("PERFLAB_HIDDEN"), out bool hidden);
62+
Boolean.TryParse(environment.GetEnvironmentVariable("PERFLAB_HIDDEN"), out var hidden);
6363
run.Hidden = hidden;
6464
var configs = environment.GetEnvironmentVariable("PERFLAB_CONFIGS");
6565
if (!String.IsNullOrEmpty(configs)) // configs should be optional.
@@ -135,7 +135,7 @@ public string GetJson()
135135

136136
public string WriteResultTable()
137137
{
138-
StringBuilder ret = new StringBuilder();
138+
var ret = new StringBuilder();
139139
foreach (var test in tests)
140140
{
141141
var defaultCounter = test.Counters.Single(c => c.DefaultCounter);
@@ -162,9 +162,9 @@ public string WriteResultTable()
162162
}
163163
private string Print(Counter counter, int counterWidth, int resultWidth)
164164
{
165-
string average = $"{counter.Results.Average():F3} {counter.MetricName}";
166-
string max = $"{counter.Results.Max():F3} {counter.MetricName}";
167-
string min = $"{counter.Results.Min():F3} {counter.MetricName}";
165+
var average = $"{counter.Results.Average():F3} {counter.MetricName}";
166+
var max = $"{counter.Results.Max():F3} {counter.MetricName}";
167+
var min = $"{counter.Results.Min():F3} {counter.MetricName}";
168168
return $"{LeftJustify(counter.Name, counterWidth)}|{LeftJustify(average, resultWidth)}|{LeftJustify(min, resultWidth)}|{LeftJustify(max, resultWidth)}";
169169
}
170170

src/tools/ScenarioMeasurement/SizeOnDisk/MStatProcessor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ static List<Result> GetBlobStats(TypeDefinition globalType)
5555
sealed record TypeStats(TypeReference Type, int Size);
5656
static IEnumerable<TypeStats> GetTypes(Version version, MethodDefinition types)
5757
{
58-
int entrySize = version.Major == 1 ? 2 : 3;
58+
var entrySize = version.Major == 1 ? 2 : 3;
5959

6060
types.Body.SimplifyMacros();
6161
var il = types.Body.Instructions;
62-
for (int i = 0; i + entrySize < il.Count; i += entrySize)
62+
for (var i = 0; i + entrySize < il.Count; i += entrySize)
6363
{
6464
var type = (TypeReference)il[i + 0].Operand;
6565
var size = (int)il[i + 1].Operand;
@@ -70,11 +70,11 @@ static IEnumerable<TypeStats> GetTypes(Version version, MethodDefinition types)
7070
sealed record MethodStats(MethodReference Method, int Size, int GcInfoSize, int EhInfoSize);
7171
static IEnumerable<MethodStats> GetMethods(Version version, MethodDefinition methods)
7272
{
73-
int entrySize = version.Major == 1 ? 4 : 5;
73+
var entrySize = version.Major == 1 ? 4 : 5;
7474

7575
methods.Body.SimplifyMacros();
7676
var il = methods.Body.Instructions;
77-
for (int i = 0; i + entrySize < il.Count; i += entrySize)
77+
for (var i = 0; i + entrySize < il.Count; i += entrySize)
7878
{
7979
var method = (MethodReference)il[i + 0].Operand;
8080
var size = (int)il[i + 1].Operand;
@@ -88,7 +88,7 @@ static IEnumerable<Result> GetBlobs(MethodDefinition blobs)
8888
{
8989
blobs.Body.SimplifyMacros();
9090
var il = blobs.Body.Instructions;
91-
for (int i = 0; i + 2 < il.Count; i += 2)
91+
for (var i = 0; i + 2 < il.Count; i += 2)
9292
{
9393
var name = (string)il[i + 0].Operand;
9494
var size = (int)il[i + 1].Operand;

src/tools/ScenarioMeasurement/SizeOnDisk/SizeOnDisk.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ static int Main(string scenarioName,
4040

4141
var counters = new List<Counter>();
4242
long totalSize = 0;
43-
int totalCount = 0;
44-
bool directoryIsTop = dirs.Length > 1; // if we were asked to log more than one directory, include the summary info as top counters.
43+
var totalCount = 0;
44+
var directoryIsTop = dirs.Length > 1; // if we were asked to log more than one directory, include the summary info as top counters.
4545
var buckets = new Dictionary<string, (long size, int count, bool isTop)>();
4646
foreach (var directory in directories)
4747
{

src/tools/ScenarioMeasurement/Startup.Tests/StartupTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public class StartupTests
1919
[WindowsOnly]
2020
public void TestWindowsTraceSession()
2121
{
22-
string sessionName = "test-windows-session";
23-
string traceName = "test-windows-trace";
22+
var sessionName = "test-windows-session";
23+
var traceName = "test-windows-trace";
2424
var session = new WindowsTraceSession(sessionName, traceName, traceDirectory, logger);
2525
var parser = new TimeToMainParser();
2626
TestSession(session, parser);
@@ -29,8 +29,8 @@ public void TestWindowsTraceSession()
2929
[LinuxOnly]
3030
public void TestLinuxTraceSession()
3131
{
32-
string sessionName = "test-linux-session";
33-
string traceName = "test-linux-trace";
32+
var sessionName = "test-linux-session";
33+
var traceName = "test-linux-trace";
3434
var session = new LinuxTraceSession(sessionName, traceName, traceDirectory, logger);
3535
var parser = new TimeToMainParser();
3636
TestSession(session, parser);
@@ -39,8 +39,8 @@ public void TestLinuxTraceSession()
3939
[WindowsOnly(Skip = "Skipping test until asset is provided")]
4040
public void TestProfileIteration()
4141
{
42-
string sessionName = "test-profile-iteration-session";
43-
string traceName = "test-profile-iteration-trace";
42+
var sessionName = "test-profile-iteration-session";
43+
var traceName = "test-profile-iteration-trace";
4444
var timeToMainParser = new TimeToMainParser();
4545
var profileParser = new ProfileParser(timeToMainParser);
4646
var profileSession = TraceSessionManager.CreateSession(sessionName, traceName, traceDirectory, logger);
@@ -50,11 +50,11 @@ public void TestProfileIteration()
5050
[Fact(Skip = "Skipping test until asset is provided")]
5151
public void TestProcessTimeParserLinux()
5252
{
53-
string ctfFile = Path.Combine(testAssetDirectory, "test-process-time_startup.trace.zip");
53+
var ctfFile = Path.Combine(testAssetDirectory, "test-process-time_startup.trace.zip");
5454
var parser = new ProcessTimeParser();
5555
var pids = new List<int>() { 18627, 18674, 18721, 18768, 18813 };
56-
IEnumerable<Counter> counters = parser.Parse(ctfFile, "dotnet", pids, "\"dotnet\" build");
57-
int count = 0;
56+
var counters = parser.Parse(ctfFile, "dotnet", pids, "\"dotnet\" build");
57+
var count = 0;
5858
foreach (var counter in counters)
5959
{
6060
Assert.True(counter.Results.Count == pids.Count, $"Counter {counter.Name} is expected to have {pids.Count} results.");
@@ -66,11 +66,11 @@ public void TestProcessTimeParserLinux()
6666
[Fact(Skip = "Skipping test until asset is provided")]
6767
public void TestProcessTimeParserWindows()
6868
{
69-
string etlFile = Path.Combine(testAssetDirectory, "test-process-time_startup.etl");
69+
var etlFile = Path.Combine(testAssetDirectory, "test-process-time_startup.etl");
7070
var parser = new ProcessTimeParser();
7171
var pids = new List<int>() { 32752, 6352, 16876, 10500, 17784 };
72-
IEnumerable<Counter> counters = parser.Parse(etlFile, "dotnet", pids, "\"dotnet\" build");
73-
int count = 0;
72+
var counters = parser.Parse(etlFile, "dotnet", pids, "\"dotnet\" build");
73+
var count = 0;
7474
foreach (var counter in counters)
7575
{
7676
Assert.True(counter.Results.Count == pids.Count, $"Counter {counter.Name} is expected to have {pids.Count} results.");
@@ -82,11 +82,11 @@ public void TestProcessTimeParserWindows()
8282
[Fact(Skip = "Skipping test until asset is provided")]
8383
public void TestTimeToMainParserLinux()
8484
{
85-
string ctfFile = Path.Combine(testAssetDirectory, "test-time-to-main_startup.trace.zip");
85+
var ctfFile = Path.Combine(testAssetDirectory, "test-time-to-main_startup.trace.zip");
8686
var parser = new TimeToMainParser();
8787
var pids = new List<int>() { 24352, 24362, 24371, 24380, 24389 };
88-
IEnumerable<Counter> counters = parser.Parse(ctfFile, "emptycsconsoletemplate", pids, "\"pub\\emptycsconsoletemplate.exe\"");
89-
int count = 0;
88+
var counters = parser.Parse(ctfFile, "emptycsconsoletemplate", pids, "\"pub\\emptycsconsoletemplate.exe\"");
89+
var count = 0;
9090
foreach (var counter in counters)
9191
{
9292
Assert.True(counter.Results.Count == pids.Count, $"Counter {counter.Name} is expected to have {pids.Count} results.");
@@ -99,11 +99,11 @@ public void TestTimeToMainParserLinux()
9999
[Fact(Skip = "Skipping test until asset is provided")]
100100
public void TestTimeToMainParserWindows()
101101
{
102-
string etlFile = Path.Combine(testAssetDirectory, "test-time-to-main_startup.etl");
102+
var etlFile = Path.Combine(testAssetDirectory, "test-time-to-main_startup.etl");
103103
var parser = new TimeToMainParser();
104104
var pids = new List<int>() { 17036, 21640, 12912, 19764, 11624 };
105-
IEnumerable<Counter> counters = parser.Parse(etlFile, "emptycsconsoletemplate", pids, "\"pub\\emptycsconsoletemplate.exe\"");
106-
int count = 0;
105+
var counters = parser.Parse(etlFile, "emptycsconsoletemplate", pids, "\"pub\\emptycsconsoletemplate.exe\"");
106+
var count = 0;
107107
foreach (var counter in counters)
108108
{
109109
Assert.True(counter.Results.Count == pids.Count, $"Counter {counter.Name} is expected to have {pids.Count} results.");
@@ -115,7 +115,7 @@ public void TestTimeToMainParserWindows()
115115

116116
private void TestSession(ITraceSession session, IParser parser)
117117
{
118-
string traceFilePath = "";
118+
var traceFilePath = "";
119119
using (session)
120120
{
121121
session.EnableProviders(parser);

src/tools/ScenarioMeasurement/Startup/Crossgen2Parser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ private void ParseStopEvent(TraceEvent evt, TraceSourceManager source)
167167
// time elapsed between each pair as the interval of this event.
168168

169169
// Get time elapsed for this pair of start&stop events
170-
double interval = evt.TimeStampRelativeMSec - Start;
170+
var interval = evt.TimeStampRelativeMSec - Start;
171171
// If previous pid exists, this is the same process and time elapsed is added to the last value in the stack.
172172
if (PrevPid.HasValue && evt.ProcessID == PrevPid)
173173
{
174-
double lastValue = Intervals.Pop();
174+
var lastValue = Intervals.Pop();
175175
Intervals.Push(lastValue + interval);
176176
}
177177
// If previous pid doesn't exist, this is the next process and time elapsed is a new value pushed to the stack.

src/tools/ScenarioMeasurement/Startup/DeviceTimeToMain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ public void EnableUserProviders(ITraceSession user)
2828
public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, IList<int> pids, string commandLine)
2929
{
3030
var times = new List<double>();
31-
Regex totalTimePattern = new Regex(@"TotalTime:\s(?<totalTime>.+)");
31+
var totalTimePattern = new Regex(@"TotalTime:\s(?<totalTime>.+)");
3232

3333
if (File.Exists(mergeTraceFile))
3434
{
35-
using(StreamReader sr = new StreamReader(mergeTraceFile))
35+
using(var sr = new StreamReader(mergeTraceFile))
3636
{
37-
string line = sr.ReadToEnd();
38-
MatchCollection finds = totalTimePattern.Matches(line);
37+
var line = sr.ReadToEnd();
38+
var finds = totalTimePattern.Matches(line);
3939
Console.WriteLine($"Found Startup Times: {finds.Count}");
4040
foreach (Match match in finds)
4141
{
42-
GroupCollection groups = match.Groups;
42+
var groups = match.Groups;
4343
Console.WriteLine($"Found Value (ms): {groups["totalTime"].Value}");
4444
times.Add(Double.Parse(groups["totalTime"].Value));
4545
}

src/tools/ScenarioMeasurement/Startup/DotnetWatchParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
3131
var ins = new Dictionary<int, double>();
3232
double start = -1;
3333
int? pid = null;
34-
bool firstHotReload = true;
34+
var firstHotReload = true;
3535
using (var source = new TraceSourceManager(mergeTraceFile))
3636
{
3737

src/tools/ScenarioMeasurement/Startup/InnerLoopMsBuildParser.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
2929
double start = -1;
3030
double buildEvalStart = -1;
3131
int? pid = null;
32-
Dictionary<string, List<double>> firstRun = new Dictionary<string, List<double>>();
33-
Dictionary<string, List<double>> secondRun = new Dictionary<string, List<double>>();
34-
Dictionary<string, List<double>> currentRun = firstRun;
32+
var firstRun = new Dictionary<string, List<double>>();
33+
var secondRun = new Dictionary<string, List<double>>();
34+
var currentRun = firstRun;
3535
using (var source = new TraceSourceManager(mergeTraceFile))
3636
{
3737

@@ -141,19 +141,19 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
141141
source.Process();
142142
}
143143

144-
List<double> diffGS = new List<double>();
145-
List<double> diffTOT = new List<double>();
146-
List<double> diffEBT = new List<double>();
144+
var diffGS = new List<double>();
145+
var diffTOT = new List<double>();
146+
var diffEBT = new List<double>();
147147

148-
for(int i = 0; i < firstRun["Process/Stop"].Count; i++)
148+
for(var i = 0; i < firstRun["Process/Stop"].Count; i++)
149149
{
150150
diffGS.Add(firstRun["Process/Stop"][i] - secondRun["Process/Stop"][i]);
151151
}
152-
for(int i = 0; i < firstRun["ThreadCSwitch"].Count; i++)
152+
for(var i = 0; i < firstRun["ThreadCSwitch"].Count; i++)
153153
{
154154
diffTOT.Add(firstRun["ThreadCSwitch"][i] - secondRun["ThreadCSwitch"][i]);
155155
}
156-
for(int i = 0; i < firstRun["Evaluate/Stop"].Count; i++)
156+
for(var i = 0; i < firstRun["Evaluate/Stop"].Count; i++)
157157
{
158158
diffEBT.Add(firstRun["Evaluate/Stop"][i] - secondRun["Evaluate/Stop"][i]);
159159
}

src/tools/ScenarioMeasurement/Startup/InnerLoopParser.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
4040
var ins = new Dictionary<int, double>();
4141
double start = -1;
4242
int? pid = null;
43-
List<List<double>> firstRun = new List<List<double>>();
44-
List<List<double>> secondRun = new List<List<double>>();
43+
var firstRun = new List<List<double>>();
44+
var secondRun = new List<List<double>>();
4545
using (var source = new TraceSourceManager(mergeTraceFile))
4646
{
4747

@@ -146,13 +146,13 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
146146
source.Process();
147147
}
148148

149-
List<double> diffGS = new List<double>();
150-
List<double> diffTOT = new List<double>();
151-
for(int i = 0; i < firstRun[0].Count; i++)
149+
var diffGS = new List<double>();
150+
var diffTOT = new List<double>();
151+
for(var i = 0; i < firstRun[0].Count; i++)
152152
{
153153
diffGS.Add(firstRun[0][i] - secondRun[0][i]);
154154
}
155-
for(int i = 0; i < firstRun[1].Count; i++)
155+
for(var i = 0; i < firstRun[1].Count; i++)
156156
{
157157
diffTOT.Add(firstRun[1][i] - secondRun[1][i]);
158158
}

src/tools/ScenarioMeasurement/Startup/PDNStartupParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
4343

4444
source.Kernel.ProcessStart += evt =>
4545
{
46-
string commandLineArgs = commandLine.Substring(commandLine.LastIndexOf("\"")+1).Trim();
47-
string payloadCommandLineArgs = evt.CommandLine.Substring(evt.CommandLine.LastIndexOf("\"")+1).Trim();
46+
var commandLineArgs = commandLine.Substring(commandLine.LastIndexOf("\"")+1).Trim();
47+
var payloadCommandLineArgs = evt.CommandLine.Substring(evt.CommandLine.LastIndexOf("\"")+1).Trim();
4848
if (processName.Equals(evt.ProcessName, StringComparison.OrdinalIgnoreCase) && pids.Contains(evt.ProcessID) && payloadCommandLineArgs == commandLineArgs)
4949
{
5050
if (pid.HasValue)

0 commit comments

Comments
 (0)