How to trace build time in Visual Studio 2008

Visual studio exposes some macro funcionality, what you can use to trace some studio build events. To start VBA editor in VS, go to Tools\Macros\Macros IDE (or Alt + F11)

Go to Environment Events module, and add following code:

 Dim BuildTime As Date
Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope,Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
        BuildTime = Now()
    End Sub
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
        Dim win As Window = _
        Dim ow As OutputWindow = win.Object
Dim owPane As OutputWindowPane
        ow.ActivePane.OutputString("Build taken (ms): " + (Now() - BuildTime).TotalMilliseconds().ToString())
    End Sub
So the module will looks like this:
After that, just Save Macro editor module, and after that, your Visual studio normal commands, like:
Build Solution, Build, Rebuld, etc.. will display following informations:

—— Build started: Project: csc, Configuration: Debug Any CPU ——
csc -> C:\Users\USERNAME\Documents\Visual Studio 2008\Projects\csc\csc\bin\Debug\csc.exe
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Build taken (ms): 67


This could ba a good start for exact measuring of build speed improvements I wanted to do.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s