给vc添加编译时间计时
2005-02-14 13:39
267 查看
利用VC的宏实现编译时间统计,做法就是添加两个宏给VC的IDE,
Sub Application_BeforeBuildStart()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
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 也签,那里显示的就是编译所耗费的时间。
Sub Application_BeforeBuildStart()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
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 也签,那里显示的就是编译所耗费的时间。
相关文章推荐
- 给VC程序添加版本号与编译时间
- VC使用编译时间作为版本号
- c语言中如何添加计时函数,统计程序执行的时间
- VC++ 工程添加 Unicode Debug和Unicode Release编译支持
- 转利用_DATE_和_TIME_宏在keil中添加编译日期和时间到C51程序中
- vc 中添加 时间控件,尤其是小时分钟控件
- linux 程序、动态库、静态库内部添加版本号和编译时间
- linux 程序、动态库、静态库内部添加版本号和编译时间详解
- c语言中如何添加计时函数,统计程序执行的时间
- c语言中如何添加计时函数,统计程序执行的时间
- 如何在VC代码里添加TODO编译警告
- [C] c99int(让VC等编译器自动兼容C99的整数类型)V1.02。源码托管到github、添加CMake编译配置文件、使用doxygen规范注释
- VC++ 工程添加 Unicode Debug 和 Unicode Release编译支持
- 转利用_DATE_和_TIME_宏在keil中添加编译日期和时间到C51程序中
- android 添加库的编译时间
- c语言中如何添加计时函数,统计程序执行的时间
- c语言中如何添加计时函数,统计程序执行的时间
- Android之版本-自动添加编译时间-自动修改版本号
- C#添加编译时间
- VC使用编译时间作为版本号标识