Home > Web Automation Specific > How To Measure Response Time

How To Measure Response Time

WinTask provides several timing functions that can be used to measure the performance of the application being automated. The same functions can be used to measure web page performance.

The following script opens the Demonstration WinTask web site, links to the Form web page, and clicks the Urgent request checkbox.

StartBrowser("IE","www.wintask.com/demos")

UsePage("WinTask Demonstration Pages")
        ClickHTMLElement("A[INNERTEXT= 'Form']")

UsePage("Form")
        ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")

CloseBrowser()

If we were interested in determining the time that it takes for the Form web page to load from the time that the Form link was clicked, the script can be modified to add timing instrumentation. The modified script below measures the response time and displays the result in a message to the user.

StartBrowser("IE","www.wintask.com/demos")

UsePage("WinTask Demonstration Pages")

' Suppress errors in case the page doesn't load. We don't want the script to terminate early.
    #IgnoreErrors = 1

' Reset system timer #1 and start performance timing
    ResetTimer(1)
    StartTimer(1)

' Click link to Form page.
    ClickHTMLElement("A[INNERTEXT= 'Form']")

' Save result of function.
    Ret = UsePage("Form")
    ' Comment out since we're not measuring the checkbox selection.
    ' ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")

' Stop system timer #1.
    StopTimer(1)

' Check whether the page loaded, report the results either way.
    If (Ret <> 0) Then
        ' Page failed to load, report the error.
        MsgBox("Error: Form page not found")
    Else
        ' Page loaded, report the time needed to load the page.
        ' System timer #1 contains the elapsed time in hundredths of a second.
        MsgBox("Form page loaded in " + Str$(Timer(1)) + " hundredths of second")
    EndIf

CloseBrowser()

It's then possible to add a loop and store in an Excel file each response time measure:

'Declare the array for storing the results
    Dim measure$(100)

'add the loop in the script above
    i=0
    repeat 
    StartBrowser("IE","www.wintask.com/demos",3)
    ....
' Stop system timer #1.
    StopTimer(1)

' Check whether the page loaded, report the results either way.
    If (Ret <> 0) Then
        ' Page failed to load, report the error.
        MsgBox("Error: Trial Offer page not found")
    Else
        ' Page loaded, store in measure$ array the result, time needed to load the page.
        ' System timer #1 contains the elapsed time in hundredths of a second.
        measure$(i)=Str$(Timer(1)
    EndIf

CloseBrowser()

'Pause 5 seconds before running a new iteration
    Pause 5 secs
    EndPause

i=i+1
    until i = 100

'Write the results in an Excel file
    fileexcel$="c:\wttest\measure.xlsx"
    CreateExcelfile(fileexcel$)
    WriteExcel(fileexcel$,"A1:A100",measure$())


See also

Introduction
Web Synchronization
Web Advanced Synchronization
HTML Descriptor
HTML Descriptor Advanced
Data Driven Automation