Skip to content

Commit

Permalink
Small refactoring around PerfLabGenericEventSource (#3104)
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet authored Jun 28, 2023
1 parent dd14c7d commit a4d0c85
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
15 changes: 6 additions & 9 deletions src/tools/ScenarioMeasurement/Startup/GenericStartupParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@

namespace ScenarioMeasurement;

// [EventSource(Guid = "9bb228bd-1033-5cf0-1a56-c2dbbe0ebc86")]
// class PerfLabGenericEventSource : EventSource
// {
// public static PerfLabGenericEventSource Log = new PerfLabGenericEventSource();
// public void Startup() => WriteEvent(1);
// }

public class GenericStartupParser : IParser
{
// see src\scenarios\staticdeps\PerfLab.cs
public const string PerfLabGenericEventSourceName = "PerfLabGenericEventSource";
public const string StartupEventName = "Startup";

public void EnableKernelProvider(ITraceSession kernel)
{
kernel.EnableKernelProvider(TraceSessionManager.KernelKeyword.Process, TraceSessionManager.KernelKeyword.Thread, TraceSessionManager.KernelKeyword.ContextSwitch);
}

public void EnableUserProviders(ITraceSession user)
{
user.EnableUserProvider("PerfLabGenericEventSource", TraceEventLevel.Verbose);
user.EnableUserProvider(PerfLabGenericEventSourceName, TraceEventLevel.Verbose);
}

public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, IList<int> pids, string commandLine)
Expand Down Expand Up @@ -71,7 +68,7 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
}
};

source.Dynamic.AddCallbackForProviderEvent("PerfLabGenericEventSource", "Startup", evt =>
source.Dynamic.AddCallbackForProviderEvent(PerfLabGenericEventSourceName, StartupEventName, evt =>
{
if (pid.HasValue && evt.ProcessID == pid && evt.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase))
{
Expand Down
7 changes: 0 additions & 7 deletions src/tools/ScenarioMeasurement/Startup/PDNStartupParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

namespace ScenarioMeasurement;

// [EventSource(Guid = "9bb228bd-1033-5cf0-1a56-c2dbbe0ebc86")]
// class PerfLabGenericEventSource : EventSource
// {
// public static PerfLabGenericEventSource Log = new PerfLabGenericEventSource();
// public void Startup() => WriteEvent(1);
// }

public class PDNStartupParser : IParser
{
const string PaintDotNetTraceProviderName = "PaintDotNetTrace";
Expand Down
7 changes: 3 additions & 4 deletions src/tools/ScenarioMeasurement/Startup/WinUIBlazorParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace ScenarioMeasurement;
public class WinUIBlazorParser : IParser
{
const string WinUIProvider = "Microsoft-Windows-XAML";
const string PerfProvider = "PerfLabGenericEventSource";

public void EnableKernelProvider(ITraceSession kernel)
{
Expand All @@ -18,7 +17,7 @@ public void EnableKernelProvider(ITraceSession kernel)
public void EnableUserProviders(ITraceSession user)
{
user.EnableUserProvider(WinUIProvider, TraceEventLevel.Verbose);
user.EnableUserProvider(PerfProvider, TraceEventLevel.Verbose);
user.EnableUserProvider(GenericStartupParser.PerfLabGenericEventSourceName, TraceEventLevel.Verbose);
}

public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, IList<int> pids, string commandLine)
Expand Down Expand Up @@ -78,7 +77,7 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
}
});

source.Dynamic.AddCallbackForProviderEvent(PerfProvider, "Startup", evt =>
source.Dynamic.AddCallbackForProviderEvent(GenericStartupParser.PerfLabGenericEventSourceName, GenericStartupParser.StartupEventName, evt =>
{
if (pid.HasValue && evt.ProcessID == pid && evt.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase))
{
Expand All @@ -99,4 +98,4 @@ public IEnumerable<Counter> Parse(string mergeTraceFile, string processName, ILi
new Counter() { Name = "Time on Thread", MetricName = "ms", TopCounter=true, Results = threadTimes.ToArray() }
};
}
}
}

0 comments on commit a4d0c85

Please sign in to comment.