{"id":6082,"date":"2023-03-20T16:57:07","date_gmt":"2023-03-20T23:57:07","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/pix\/?p=6082"},"modified":"2023-03-21T11:01:48","modified_gmt":"2023-03-21T18:01:48","slug":"programmatic-timing-captures-now-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/pix\/programmatic-timing-captures-now-available\/","title":{"rendered":"Programmatic Timing Captures now available"},"content":{"rendered":"<p>As described in <a href=\"https:\/\/devblogs.microsoft.com\/pix\/programmatic-capture\/\">Programmatic Captures<\/a>, the <span style=\"font-family: 'courier new', courier, monospace;\">PIXBeginCapture<\/span> and <span style=\"font-family: 'courier new', courier, monospace;\">PIXEndCapture<\/span> can now be used to start and stop <a href=\"https:\/\/devblogs.microsoft.com\/pix\/timing-captures-new\/\">Timing Captures<\/a> from code running in your title.\u00a0 Programmatic Timing Captures are available starting with the <a href=\"https:\/\/devblogs.microsoft.com\/pix\/pix-2303-02\/\">2303.02 release of PIX on Windows<\/a> and version 1.0.230302001 of the <a href=\"https:\/\/devblogs.microsoft.com\/pix\/winpixeventruntime\/\">WinPIXEventRuntime<\/a>.<\/p>\n<p>Timing captures use several ETW providers.\u00a0 This dependency requires your title to be running with administrator privileges to be able to take programmatic captures.\u00a0 Also note that a helper dll, <span style=\"font-family: 'courier new', courier, monospace;\">WinPixTimingCapturer.dll<\/span>, must be loaded before calling <span style=\"font-family: 'courier new', courier, monospace;\">PIXBeginCapture<\/span>.\u00a0 The easiest way to load this dll is by calling the <span style=\"font-family: 'courier new', courier, monospace;\">PIXLoadLatestWinPixTimingCapturerLibrary<\/span> helper function.<\/p>\n<p>The following code sample loads the helper dll, calls <span style=\"font-family: 'courier new', courier, monospace;\">PIXBeginCapture<\/span> to start the capture, then calls <span style=\"font-family: 'courier new', courier, monospace;\">PIXEndCapture<\/span> to end the capture.\u00a0 At this time, the <span style=\"font-family: 'courier new', courier, monospace;\">discard<\/span> parameter to <span style=\"font-family: 'courier new', courier, monospace;\">PIXEndCapture<\/span> is ignored.<\/p>\n<pre class=\"prettyprint language-cpp\"><code class=\"language-cpp\">        #include pix3.h        \r\n         \r\n        g_hTimingCapturer = PIXLoadLatestWinPixTimingCapturerLibrary();\r\n        if (g_hTimingCapturer == NULL)\r\n        {\r\n            \/\/ process error\r\n        }\r\n\r\n        PIXCaptureParameters captureParams = {};\r\n\r\n        captureParams.TimingCaptureParameters.FileName = L\"c:\\\\captures\\\\hitch_detected.wpix\";\r\n        captureParams.TimingCaptureParameters.CaptureCpuSamples = true;\r\n        captureParams.TimingCaptureParameters.CaptureCallstacks = true;\r\n        captureParams.TimingCaptureParameters.CpuSamplesPerSecond = 4000;\r\n\r\n        HRESULT hrProgCapture = PIXBeginCapture(PIX_CAPTURE_TIMING, &amp;captureParams);\r\n\r\n        if (!SUCCEEDED(hrProgCapture))\r\n        {\r\n            \/\/ process error\r\n        }\r\n        \r\n        \/\/ title code runs\r\n        HRESULT hrEndCapture = PIXEndCapture(false);\r\n\r\n        if (!SUCCEEDED(hrEndCapture))\r\n        {\r\n            \/\/ process error\r\n        }<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>See <a href=\"https:\/\/devblogs.microsoft.com\/pix\/programmatic-capture\/\">Programmatic Captures<\/a> for more information on the programmatic capture APIs and the <span style=\"font-family: 'courier new', courier, monospace;\">PIXCaptureParameters<\/span> structure.<\/p>\n<p>Steven.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As described in Programmatic Captures, the PIXBeginCapture and PIXEndCapture can now be used to start and stop Timing Captures from code running in your title.\u00a0 Programmatic Timing Captures are available starting with the 2303.02 release of PIX on Windows and version 1.0.230302001 of the WinPIXEventRuntime. Timing captures use several ETW providers.\u00a0 This dependency requires your [&hellip;]<\/p>\n","protected":false},"author":1915,"featured_media":4769,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6082","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pix"],"acf":[],"blog_post_summary":"<p>As described in Programmatic Captures, the PIXBeginCapture and PIXEndCapture can now be used to start and stop Timing Captures from code running in your title.\u00a0 Programmatic Timing Captures are available starting with the 2303.02 release of PIX on Windows and version 1.0.230302001 of the WinPIXEventRuntime. Timing captures use several ETW providers.\u00a0 This dependency requires your [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/6082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/users\/1915"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/comments?post=6082"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/6082\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media\/4769"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media?parent=6082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/categories?post=6082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/tags?post=6082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}