如何使用Windows性能分析器查看EventSource创建的ETW事件?

时间:2013-01-19 06:04:50

标签: c# performance etw wpa

我想使用EventSource触发ETW事件,并使用Windows性能分析器查看它们。

我有一个基本的EventSource

[EventSource(Name = "BasicEventSource")]
public class ETWLogger : EventSource
{
#if DEBUG
    private const bool ThrowOnError = true;
#else
    private const bool ThrowOnError = false;
#endif

    private ETWLogger(bool throwOnError) : base(throwOnError) { }

    private static ETWLogger _log;
    public static ETWLogger Log
    { get { return _log ?? (_log = new ETWLogger(ThrowOnError)); } }

    private static class Keywords
    {
        public const EventKeywords Perf = (EventKeywords) 1;
    }

    [Event(1, Keywords = Keywords.Perf, Level = EventLevel.Informational)]
    public void Startup() { WriteEvent(1, "StartUp"); }
}

当我使用Windows性能记录器(WPR)录制时,我在Windows性能分析器(WPA)的通用事件图表中看不到我的提供者或事件。

感谢您的时间:)

2 个答案:

答案 0 :(得分:1)

WPR和WPA不支持EventSource,但使用新的8.1 ​​ADK。请参阅here

答案 1 :(得分:1)

WPR对您的自定义EventSource一无所知,因此您必须创建录制配置文件,以便启用它。 WPT附带了几个示例配置文件,可以帮助您入门。

8.1版本的WPR支持与PerfView相同的命名约定,这意味着您可以在配置文件中使用*YourEventSource而不是GUID。

根据我的经验,8.1版本的WPA中没有很好地支持某些EventSource功能。例如。如果您使用任务,他们将无法正确显示。但是,当您为EventSource创建录制配置文件时,EventSource的基本用法适用于8.1版本的WPA / WPR。

另一种选择是使用PerfView收集跟踪并使用WPA进行分析(如果您更喜欢使用PerfView)。