给vc添加编译时间计时

利用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 也签,那里显示的就是编译所耗费的时间。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值