Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Build Duration Macro

0.00/5 (No votes)
1 Oct 2001 1  
A DevStudio macro that displays the project's build duration

Introduction

This macro adds a missing feature to DevStudio6. It displays project build duration. You'll see a new tab named Macro in the output window (next to the standard tabs: Build, Debug, Find in files...)

Open your macro file and insert the following line before any other functions or subroutines.

Public dBuildStartTime

Next, place the code below somewhere in your macro file. These events (Application_BeforeBuildStart and Application_BuildFinish) will be automatically triggered by DevStudio when you build your projects.

Sub Application_BeforeBuildStart()
	' keep the build-starting time
	dBuildStartTime = Now
	Application.PrintToOutputWindow " "
	Application.PrintToOutputWindow "--------------------------------"
	Application.PrintToOutputWindow "Build start: " & dBuildStartTime
End Sub

Sub Application_BuildFinish(nNumErrors, nNumWarnings)
	
	' get build time
	dNow = Now

	sec = DateDiff("s", dBuildStartTime, dNow)

	hours = sec \ 3600
	sec = sec - hours * 3600

	min = sec \ 60
	sec = sec - min * 60

	' format
	Dim strH, strM, strS

	If hours > 10 Then
		strH = hours
	Else
		strH = "0" & hours
	End If

	If min > 10 Then
		strM = min
	Else
		strM = "0" & min
	End If

	If sec > 10 Then
		strS = sec
	Else
		strS = "0" & sec
	End If

	' display
	Application.PrintToOutputWindow "Build end:   " & dNow
	Application.PrintToOutputWindow "Build time:  " & strH & ":" & strM & ":" & strS
	Application.PrintToOutputWindow nNumWarnings & " warning(s), " & nNumErrors & " error(s)."

End Sub

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here