Skip to content

Commit 97687bf

Browse files
committed
enable trace collection for microbenchmarks on Linux
1 parent 7456e69 commit 97687bf

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/benchmarks/gc/GC.Infrastructure/GC.Infrastructure.Core/Analysis/Microbenchmarks/MicrobenchmarkResultsAnalyzer.cs

+2-15
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,10 @@ public static IReadOnlyDictionary<Run, ConcurrentDictionary<string, Microbenchma
4848

4949
foreach (var analyzer in analyzers)
5050
{
51-
List<GCProcessData> allPertinentProcesses = analyzer.Value.GetProcessGCData("dotnet");
52-
List<GCProcessData> corerunProcesses = analyzer.Value.GetProcessGCData("corerun");
53-
allPertinentProcesses.AddRange(corerunProcesses);
5451
foreach (var benchmark in runsToResults[run.Value])
5552
{
56-
GCProcessData? benchmarkGCData = null;
57-
foreach (var process in allPertinentProcesses)
58-
{
59-
string commandLine = process.CommandLine.Replace("\"", "").Replace("\\", "");
60-
string runCleaned = benchmark.Key.Replace("\"", "").Replace("\\", "");
61-
if (commandLine.Contains(runCleaned) && commandLine.Contains("--benchmarkName"))
62-
{
63-
benchmarkGCData = process;
64-
break;
65-
}
66-
}
67-
53+
GCProcessData? benchmarkGCData = analyzer.Value.GetProcessGCData("MicroBenchmarks").FirstOrDefault();
54+
6855
if (benchmarkGCData != null)
6956
{
7057
int processID = benchmarkGCData.ProcessID;

src/benchmarks/gc/GC.Infrastructure/GC.Infrastructure.Core/CommandBuilders/Microbenchmark.CommandBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static (string, string) Build(MicrobenchmarkConfiguration configuration,
1111
string filter = benchmark ?? configuration.MicrobenchmarkConfigurations.Filter;
1212

1313
// Base command: Add mandatory commands.
14-
string command = $"run -f {frameworkVersion} --filter \"{filter}\" -c Release --noOverwrite --no-build";
14+
string command = $"run -f {frameworkVersion} --filter \"{filter}\" -c Release --inProcess --noOverwrite --no-build";
1515

1616
// [Optional] Add corerun.
1717
if (!string.IsNullOrEmpty(run.Value.corerun))

src/benchmarks/gc/GC.Infrastructure/GC.Infrastructure/Commands/Microbenchmark/MicrobenchmarkCommand.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,19 @@ public static MicrobenchmarkOutputResults RunMicrobenchmarks(MicrobenchmarkConfi
189189
}
190190
else
191191
{
192+
Process microBenchmarksProcess = new();
192193
bdnProcess.Start();
193-
using (TraceCollector traceCollector = new TraceCollector(traceName, collectType, runPath, bdnProcess.Id))
194+
// wait for Microbenchmark to start
195+
while (true)
196+
{
197+
Process[] microBenchmarksProcessList = Process.GetProcessesByName("MicroBenchmarks");
198+
if (microBenchmarksProcessList.Count() != 0)
199+
{
200+
microBenchmarksProcess = microBenchmarksProcessList.First();
201+
break;
202+
}
203+
}
204+
using (TraceCollector traceCollector = new TraceCollector(traceName, collectType, runPath, microBenchmarksProcess.Id))
194205
{
195206
bdnProcess.BeginOutputReadLine();
196207
bdnProcess.BeginErrorReadLine();

0 commit comments

Comments
 (0)