. Net Performance Testing Tool-event tracker (ETW)

Source: Internet
Author: User

Content preview:

  • Windows built-in tools (performance counters)
  • Event tracker (WPT, perfmoniter, perfview, custom ETW)
  • Time Analysis
  • Memory Allocation Analysis
  • Memory Usage Analysis
  • Other analyses

Event tracing for Windows (ETW) allows you to view a lot of kernel and CLR performance data. As shown in the following table, several tools are developed based on ETW and will be detailed later:

Kernel Proc_thread Creation and destruction of processes and threads  
Kernel Loader Load and unload of images (DLLs, drivers, exes)  
Kernel Syscall System CILS  
Kernel Disk_io Disk I/O reads and writes (including head location)  
Kernel Hard_faults Page faults that resulted in disk I/O (not satisfied from memory)  
Kernel Profile Sampling event-a stack trace of all processors collected every 1 ms  
CLR Gckeyword Garbage collection statistics and information Collection started, collection ended, finalizers run ,~ 100kb of memory have been allocated
CLR Contentionkeyword Threads contend for a managed lock Contention starts (a thread begins waiting), contention ends
CLR Jittracingkeyword Just In Time Compiler (JIT) Information Method inlining succeeded, method inlining failed
CLR Predictionkeyword Exceptions that are thrown  

 

 

 

 

 

 

 

Windows performance Toolkit (WPT)Is a tool set of ETW to capture ETW events to log files. Can be downloaded in the http://msdn.microsoft.com/en-us/performance/cc752957.aspx.

The procedure is as follows:

  1. Set the value of _ nt_symbol_path in the environment variable to Microsoft's public symbol server and local symbol cache, such as c: \ temp \ symbols * http://msdl.microsoft.com/download/symbols
  2. Set the value of _ nt_symcache_path in the environment variable to a custom directory.
  3. Open the Administrator's cmd window and find the installation folder (for example, c: \ Program Files \ Windows kits \ 8.0 \ Windows performance Toolkit ).
  4. Run xperf-on base to start tracking kernel data
  5. Run any program
  6. Stop tracing and output logs. Xperf-D kerneltrace. ETL
  7. Open the graphic analyzer xperfview kerneltrace. ETL

The application scenarios of WPT are:

  • Capture hard disk I/O operations

  • Provides all CPU Activity

  • Display the stacked diagrams of Io, memory, CPU, etc.

  • Display call stack

The latest Windows sdk8.0 includes some new tools, such as Windows performance recorder (wpr.exe) and Windows Performance Analyzer (wpa.exe), to replace xperf and xperfview. WPR-start is the same as xperf-on, and WPR-stop is the same as xperf-D. WPA analysis UI and xperfview functions the same, more information can refer to the http://msdn.microsoft.com/en-us/library/hh162962.aspx.

Xperfview can be used to view GC event data:

 

PerfmonitorIs an open source console tool http://bcl.codeplex.com/releases/view/49601.

Perfmonitor has the advantage of analyzing Clr and JIT in more detail.

The usage is as follows:

C:\PerfMonitor > perfmonitor runAnalyze JackCompiler.exeStarting kernel tracing. Output file: PerfMonitorOutput.kernel.etlStarting user model tracing. Output file: PerfMonitorOutput.etlStarting at 4/7/2012 12:33:40 PMCurrent Directory C:\PerfMonitorExecuting: JackCompiler.exe {} Stopping at 4/7/2012 12:33:42 PM = 1.724 secStopping tracing for sessions 'NT Kernel Logger' and 'PerfMonitorSession'.Analyzing data in C:\PerfMonitor\PerfMonitorOutput.etlxGC Time HTML Report in C:\PerfMonitor\PerfMonitorOutput.GCTime.htmlJIT Time HTML Report in C:\PerfMonitor\PerfMonitorOutput.jitTime.htmlFiltering to process JackCompiler (1372). Started at 1372.000 msec.Filtering to Time region [0.000, 1391.346] msecCPU Time HTML report in C:\PerfMonitor\PerfMonitorOutput.cpuTime.htmlFiltering to process JackCompiler (1372). Started at 1372.000 msec.Perf Analysis HTML report in C:\PerfMonitor\PerfMonitorOutput.analyze.htmlPerfMonitor processing time: 7.172 secs.

The preceding statistics include:

  • CPU statistics and CPU utilization.
  • GC statistics: GC time. The maximum GC heap is 4.5 MB, the maximum memory allocation rate is 1496.1 MB/second, and the average GC pause time is 0.1 Ms.
  • JIT compilation statistics: 159 functions are compiled by JIT at runtime, with a total of 30493 machine bytes.

It indicates that the CPU does the most work in these three functions: system. String. Concat, jackcompiler. tokenizer. advance, and system. LINQ. enumerable. contains.

84.2% CPU time spent: jackcompiler. parser. parse, called parseclass, parsesubdecls, parsesubdecl, parsesubbody

 

Is the detailed statistics of some GC events:

 

Perfview:A free tool for analyzing the usage of the heap. In http://www.microsoft.com/download/en/details.aspx? Id = 28567 download.

The above report includes:

  • The original ETW event list.
  • Group of CPU time used on the stack.
  • Image loading, hard disk Io, GC stack usage.
  • GC statistics.

Perfview can also generate heap snapshots.

 

Custom ETW providers:You can also develop an ETW-based performance data statistics Tool .. Before net4.5, it was quite difficult to output ETW data, and it was much easier to. net4.5. inherit from the system. Diagnostics. Tracing. eventsource class and then call the writeevent function to output the data.

public class CustomEventSource : EventSource {public class Keywords {public const EventKeywords Loop = (EventKeywords)1;public const EventKeywords Method = (EventKeywords)2;}[Event(1, Level = EventLevel.Verbose, Keywords = Keywords.Loop,Message = "Loop {0} iteration {1}")]public void LoopIteration(string loopTitle, int iteration) {WriteEvent(1, loopTitle, iteration);}[Event(2, Level = EventLevel.Informational, Keywords = Keywords.Loop,Message = "Loop {0} done")]public void LoopDone(string loopTitle) {WriteEvent(2, loopTitle);}[Event(3, Level = EventLevel.Informational, Keywords = Keywords.Method,Message = "Method {0} done")]public void MethodDone([CallerMemberName] string methodName = null) {WriteEvent(3, methodName);}}class Program {static void Main(string[] args) {CustomEventSource log = new CustomEventSource();for (int i = 0; i < 10; ++i) {Thread.Sleep(50);log.LoopIteration("MainLoop", i);}log.LoopDone("MainLoop");Thread.Sleep(100);log.MethodDone();}}

The perfmonitor tool can automatically obtain ETW event data from the program:

C:\PerfMonitor > perfmonitor monitorDump Ch02.exeStarting kernel tracing. Output file: PerfMonitorOutput.kernel.etlStarting user model tracing. Output file: PerfMonitorOutput.etlFound Provider CustomEventSource Guid ff6a40d2-5116-5555-675b-4468e821162eEnabling provider ff6a40d2-5116-5555-675b-4468e821162e level: Verbose keywords:0xffffffffffffffffStarting at 4/7/2012 1:44:00 PMCurrent Directory C:\PerfMonitorExecuting: Ch02.exe {} Stopping at 4/7/2012 1:44:01 PM = 0.693 secStopping tracing for sessions 'NT Kernel Logger' and 'PerfMonitorSession'.Converting C:\PerfMonitor\PerfMonitorOutput.etlx to an XML file.Output in C:\PerfMonitor\PerfMonitorOutput.dump.xmlPerfMonitor processing time: 1.886 secs.

 

In fact, there is another thing calledWindows Management Instrumentation (Wmi ).It is not mentioned here, it can get the system status, BIOS firmware, and other data. Document see http://msdn.microsoft.com/en-us/library/windows/desktop/aa394582.aspx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.