Measure the response time of a Web page part I

Scripts for common tasks

Measure the response time of a Web page part I

Postby Mike on Fri Dec 04, 2009 3:51 pm

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
ResetTimer(1)

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

'Ignore the errors, the errors are managed within the script
#IgnoreErrors=1

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

'Start the main url
ret=startbrowser("IE", "www.wintask.com/demos/home_page.htm")

'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
   StartTimer(1)
   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
      stoptimer(1)
      if timer(1) > tmax_page then
         msgbox("The page took more than "+str$(tmax_page)+" to load")
         stop
      endif
   else
      msgbox("The page to measure could not be loaded")
      stop
   endif
else
   msgbox("The link to click has not been found")
   stop
endif

'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")
Mike
 
Posts: 5
Joined: Fri Dec 04, 2009 3:24 pm

Return to Sample Scripts and Tips

Who is online

Users browsing this forum: No registered users and 1 guest

cron