<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Balint&#039;s Blog &#187; visual studio performance tools profiling instrumentation</title>
	<atom:link href="http://blog.spench.net/tag/visual-studio-performance-tools-profiling-instrumentation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.spench.net</link>
	<description>balint at spench fullstop-decimalpoint-dot net</description>
	<lastBuildDate>Sun, 20 Jul 2025 18:53:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Error when instrumenting files for profiling using Visual Studio Performance Tools</title>
		<link>http://blog.spench.net/2009/08/27/error-when-instrumenting-files-for-profiling-using-visual-studio-performance-tools/</link>
		<comments>http://blog.spench.net/2009/08/27/error-when-instrumenting-files-for-profiling-using-visual-studio-performance-tools/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 08:23:23 +0000</pubDate>
		<dc:creator>balint</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[visual studio performance tools profiling instrumentation]]></category>

		<guid isPermaLink="false">http://blog.spench.net/2009/08/27/error-when-instrumenting-files-for-profiling-using-visual-studio-performance-tools/</guid>
		<description><![CDATA[A while ago I started using the Performance Tools that came bundled with Visual Studio 2005 Team Suite to analyse my code. There are two analysis methods: sampling and instrumentation. Although instrumentation has a higher overhead, it can reveal in greater detail exactly what your program is doing. In order for instrumentation to proceed, one [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I started using the Performance Tools that came bundled with Visual Studio 2005 Team Suite to analyse my code. There are two analysis methods: sampling and instrumentation. Although instrumentation has a higher overhead, it can reveal in greater detail exactly what your program is doing. In order for instrumentation to proceed, one must link with the /PROFILE switch and then use <a href="http://msdn.microsoft.com/en-us/library/ms182402%28VS.80%29.aspx">VSInstr</a> to insert counters into one&#8217;s code. To cut down the cruft collected during a profiling session, one can use the VSInstr switches to dictate exactly which functions should be instrumented and/or use the VSPerf API to command the profiling engine to start/stop/suspend/resume/mark data collection during a run.</p>
<p>One fatal flaw of the Performance Explorer in the 2005 IDE was that one couldn&#8217;t start a program with data collection in the stopped state. It would always start collecting data from the very beginning of execution. Visual Studio 2008 includes a command to &#8220;Launch with Profiling Paused&#8221;, which is a great way to only start profiling when you need to (e.g. via StartProfile or VSInstr /STARTONLY).</p>
<p>Alas, there is still a bug in the Performance Explorer (or, rather, in its build system). If one selects, through the Binary properties of a performance session, to &#8216;relocate instrumented binaries&#8217;, and then proceeds to set &#8216;additional instrumentation options&#8217; in the Advanced section, the IDE will complain when attempting to start a new profiling session and print this error message in the Output window: &#8220;Object reference not set to an instance of an object.&#8221;. This is highly annoying because it is helpful to put the instrumented binaries elsewhere (not where the original build outputs reside) AND add specific command line options, such as /VERBOSE and /CONTROL (in conjunction with the others).</p>
<p>I don&#8217;t know how to work around this bug; I had hoped it was fixed in 2008, but apparently not. The easiest thing is to not relocate the instrumented binaries. Perhaps one can add another build configuration that includes the /PROFILE linker option and uses its own folder as the build output destination where the binaries can be instrumented in-place.</p>
<p>Here are some helpful resources about using the Performance Tools:<br />
<a href="http://blogs.msdn.com/angryrichard/archive/2005/01/16/354194.aspx">http://blogs.msdn.com/angryrichard/archive/2005/01/16/354194.aspx</a><br />
<a href="http://blogs.msdn.com/scarroll/archive/2005/04/13/407981.aspx">http://blogs.msdn.com/scarroll/archive/2005/04/13/407981.aspx</a><br />
<a href="http://blogs.msdn.com/ianhu/archive/2005/06/09/427327.aspx">http://blogs.msdn.com/ianhu/archive/2005/06/09/427327.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.spench.net/2009/08/27/error-when-instrumenting-files-for-profiling-using-visual-studio-performance-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
