给vc添加编译时间计时

王朝网络·vc·作者佚名  2006-01-09
宽屏版  字体: |||超大  

利用VC的宏实现编译时间统计,做法就是添加两个宏给VC的IDE,

Sub Application_BeforeBuildStart()

dBuildStartTime = NOW

Application.PrintToOutputWindow "---------------------------------------------------TimeCount Win32 Build ----------------------------------------------------------------"

Application.PrintToOutputWindow "Build start: " & dBuildStartTime

End Sub

Sub Application_BuildFinish(nNumErrors, nNumWarnings)

' get build time

dim dNow, hours, sec

dNow = Now

hours = DateDiff("h", dBuildStartTime, dNow, vbSunday, vbFirstJan1)

min = DateDiff("n", dBuildStartTime, dNow, vbSunday, vbFirstJan1)

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

'hours = sec / 3600

sec = sec - hours * 3600

min = min - hours * 60

'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

保存之后再编译的时候就会在IDE的OutPut窗口多一个Macro 也签,那里显示的就是编译所耗费的时间。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有