{"id":104530,"date":"2020-12-09T07:00:00","date_gmt":"2020-12-09T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104530"},"modified":"2020-12-09T06:36:58","modified_gmt":"2020-12-09T14:36:58","slug":"20201209-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20201209-00\/?p=104530","title":{"rendered":"Parsing ETL traces yourself, part 1: wpaexporter"},"content":{"rendered":"<p>The <a href=\"https:\/\/docs.microsoft.com\/windows-hardware\/test\/wpt\/windows-performance-analyzer\"> Windows Performance Analyzer (WPA)<\/a> gives you a graphical view of the contents of an ETL (event trace log) file. But sometimes you want to process these log files programmatically, say, because you have a large number of these traces and you want to do some bulk analysis over them.<\/p>\n<p>One option is to use <a href=\"https:\/\/docs.microsoft.com\/windows-hardware\/test\/wpt\/exporter\"> the <tt>wpaexporter<\/tt> tool<\/a> that comes with the Windows Performance Analyzer. The idea behind this tool is that you WPA to set up a view that contains what you want to export, and then <a href=\"https:\/\/docs.microsoft.com\/windows-hardware\/test\/wpt\/apply-a-view-profile\"> save it as a profile<\/a>, let&#8217;s call it <tt>export.wpaProfile<\/tt>.<\/p>\n<p>You then feed that profile to the <tt>wpaexporter<\/tt> program alongside an ETL file, and it will load the ETL file, apply the profile, and then output the view as a comma-separated-values (CSV) file.\u00b9<\/p>\n<p>The <tt>wpaexporter<\/tt> program is a bit finicky about its command line, in ways not mentioned in <a href=\"https:\/\/docs.microsoft.com\/windows-hardware\/test\/wpt\/exporter\"> its documentation<\/a>: The command line switches are sensitive to order.<\/p>\n<p>The command line switches fall into categories, and the categories have an order. The switches within a category can appear in any order (as far as I can tell), but the categories themselves need to be ordered.<\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th>Category<\/th>\n<th>Options<\/th>\n<\/tr>\n<tr>\n<td>Inputs<\/td>\n<td><tt>-i<\/tt> <i>filename.etl<\/i><\/td>\n<\/tr>\n<tr>\n<td>Trace<\/td>\n<td><tt>-range<\/tt> <i>start<\/i> <i>end<\/i><br \/>\n<tt>-marks<\/tt> <i>start<\/i> <i>end<\/i><br \/>\n<tt>-region<\/tt> <i>name<\/i><\/td>\n<\/tr>\n<tr>\n<td>Profile<\/td>\n<td><tt>-profile<\/tt> <i>filename.wpaProfile<\/i><\/td>\n<\/tr>\n<tr>\n<td>Miscellaneous<\/td>\n<td><tt>-delimiter<\/tt> <i>char<\/i><br \/>\n<tt>-prefix<\/tt> <i>str<\/i><br \/>\n<tt>-outputfolder<\/tt> <i>foldername<\/i><br \/>\n<tt>-symbols<\/tt><br \/>\n<tt>-tti<\/tt><br \/>\n<tt>-h<\/tt><br \/>\n<tt>\/?<\/tt><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00b9 The poor-man&#8217;s version of this is to use WPA to get the view you like,\u00b2 then hit <kbd>Ctrl<\/kbd>+<kbd>A<\/kbd> to select all, then <kbd>Ctrl<\/kbd>+<kbd>C<\/kbd> to copy the view to the clipboard. You can then paste it into a text file or directly into a spreadsheet. Note, however, that the format of the copied text is almost-but-not-quite CSV: If the text in a column contains a comma, the <kbd>Ctrl<\/kbd>+<kbd>C<\/kbd> command does not protect the comma with quotation marks. This is particularly troublesome when the column contains numbers, because WPA inserts thousands separators into large numbers. You can postprocess this out by noticing that <kbd>Ctrl<\/kbd>+<kbd>C<\/kbd> uses a comma <i>followed by a space<\/i> to separate columns.<\/p>\n<p>\u00b2 Here are some handy tricks for getting the view you like:<\/p>\n<ul>\n<li>Right-click a cell and select <i>Expand Column<\/i> to expand all the nodes in this column.<\/li>\n<li>Right-click a cell and select <i>Filter To Selection<\/i> or <i>Filter Out Selection<\/i> to apply a quick filter.<\/li>\n<li>Use the View Editor (click the gear icon in the mini-title-bar or hit <kbd>Ctrl<\/kbd>+<kbd>E<\/kbd>) to configure the columns all at one go.<\/li>\n<li>In the View Editor, click <i>Advanced<\/i> to do even more stuff. My favorites are the <i>Filter<\/i> tab to apply a custom filter and the <i>Expansion<\/i> tab to preconfigure which rows are expanded.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A simple converter that spits out comma-separated values.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-104530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A simple converter that spits out comma-separated values.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=104530"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=104530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}