Page 1 of 1

Measure the response time of a Web page part I

PostPosted: Fri Dec 04, 2009 3:51 pm
by Mike
This WinTask script measures how long it takes for one web page to load, the error management is done at the function level.

Code: Select all
'Reset the timer 1 which is used for measuring the response time

'Maximum elapsed time in hundredth of a second before reporting an error

'Ignore the errors, the errors are managed within the script

'Force the exact recognition of the page, as in this example all the page titles start with the same characters

'Start the main url
ret=startbrowser("IE", "")

'click a link
UsePage("WinTask - Welcome")
   ret = ClickHTMLElement("A[INNERTEXT= 'Form']")

'Measure how long it takes for the new page to load just after the click
'Was the clickhtmlelement line successfull ? If yes (the return code ret is equal to 0),
' measure the response time of the new page it loads.
if ret=0 then
   'Start the timer
   ret=UsePage("WinTask - Form")
   'Was the UsePage successfull? If yes, the page did load and the measure can be done
   if ret = 0 then
      'Stop the timer
      if timer(1) > tmax_page then
         msgbox("The page took more than "+str$(tmax_page)+" to load")
      msgbox("The page to measure could not be loaded")
   msgbox("The link to click has not been found")

'On this small example, the result is usually 0 as the page loads immediately.
'On a page which loads slowly, the message box will contain a non-zero value.
msgbox("The page loaded in: "+str$(timer(1))+" hundredth of a second")