VBS统计页面加载时间脚本
2010-03-04 13:24
375 查看
下面是一个通过Excel中的url列表来请求页面,统计页面加载时间,然后记录到Excel中的vbs脚本。由于vbs脚本并不是这方面的最好选择,没有研究过httpWatch软件是如何实现统计页面各个元素加载时间的原理,这个脚本统计出来的时间会有偏差,数据仅供参考。以下是代码:
'Function GetCellNum() ' On Error Resume Next ' Set Wshell = CreateObject("Wscript.shell") ' Set ExcelApp = CreateObject("Excel.Application") ' ExcelApp.Visible = True ' Set newBook = ExcelApp.Workbooks.Open("C:/Report.xls") ' If Err = 0 Then ' Set excelSheet = ExcelApp.ActiveSheet ' Set rowCount = excelSheet.Rows.Count ' For i = 1 To 65535 ' GetCellValue = excelSheet.Cells(i,1) ' excelSheet.Cells(i,2) = "http://test.gasgoo.cn/TradeSearch/search/SearchNormal.aspx?idty=0.2831222238019109&sType=1&key=" & GetCellValue & "" ' excelSheet.save 'MsgBox "现在是第"&i&"行"&vbCrLf&"值为:"&GetCellValue ' Wshshell.Popup GetCellValue,2,"获取的Excel单元格的值为:",0+64 ' If GetCellValue = "" Then ' rowNum = i - 1 ' GetCellNum = rowNum ' MsgBox rowNum ' Exit For ' Else 'do nothing ' End If ' Next ' Else 'do nothing ' End If ' newBook.SaveAs("C:\KeywordUrl.xls") ' newBook.Save ' newBook.Close ' ExcelApp.Quit ' Set ExcelApp = Nothing ' Set Wshell = Nothing 'End Function 'Call GetCellNum() 'i = GetCellNum() 'MsgBox i Function CountPadLoadTime() On Error Resume Next Set Wshell = CreateObject("Wscript.shell") Set IeObject = CreateObject("InternetExplorer.Application") Set ExcelApp = CreateObject("Excel.Application") ExcelApp.Visible= True Set newBook =ExcelApp.Workbooks.Open("C:/KeywordUrl.xls") If Err = 0 Then Set excelSheet = ExcelApp.ActiveSheet For i = 1 To 65535 GetCellValue = excelSheet.Cells(i,2) If GetCellValue <> "" Then 'MsgBox GetCellValue IeObject.Navigate(GetCellValue) time1 = timer() 'MsgBox time1 a = IeObject.ReadyState IeObject.visible = True While IeObject.busy Or ( IeObject.ReadyState<>4 ) wscript.sleep 1 wend time2 = timer() 'MsgBox time2 costPageLoad = time2 - time1 'Wshshell.Popup costPageLoad,2,"页面加载时间为:",0+64 'MsgBox "页面加载时间为:"& costPageLoad excelSheet.Cells(i,3) = costPageload excelSheet.save WScript.Sleep 1000 time1 = 0 time2 = 0 costPageLoad = 0 Else Exit For End If Next End If newBook.SaveAs("c:\Results.xls") newBook.Close excelApp.Quit Call RelaeseResource() End Function Function ReleaseResource() On Error Resume Next Set excelObject = Nothing Set ExcelApp = Nothing Set IeObject = Nothing End Function Call CountPadLoadTime()
相关文章推荐
- PHP脚本统计页面执行时间
- 使用QTP统计页面加载时间(加载IE对象)
- Google Analytics新增页面加载时间统计功能
- 使用QTP统计页面加载时间
- 如何统计页面的加载时间呢
- QTP统计页面加载时间
- 统计页面加载时间
- js统计页面加载时间
- Android Activity页面加载时间性能分析,以及改进要点
- 解决:shell脚本中,无法执行time命令,以统计某个程序执行时间
- 请说出三种减少页面加载时间的方法。(加载时间指感知的时间或者实际加载时间)
- js统计网页在线时间的脚本
- VBS脚本打开ie,执行asp页面代码
- 谷歌将根据视频广告页面加载时间收费
- 一个统计Linux用户登陆时间的脚本
- shell脚本统计出日志文件操作以及其对应的平均时间
- 一段linux上统计平均响应时间的awk脚本
- 用js统计用户下载网页所需时间的脚本
- 用js统计用户下载网页所需时间的脚本
- 在WEB中为页面加载或查询时间添加loading效果