REDUCE EXECUTION TIME-METHODS
Context:
Everyone has an opinion on the matter – some insist the Object-Repository yields the best results, while others are strong advocates for working with Descriptive Programming. While one will insert every object into a variable and use that variable, another would use the objects straight from the Object-Repository, thinking it was the most efficient way.
Discussion :
I am going to test manipulated the GUI through these methods(Please make sure that we run all the methods on single instance):1)Regular use of the object repository.
iTimer = Timer
For i = 0 to 50
Browser("Google").Page("Google").WebEdit("q").Set i
Next
Print "Regular OR =" & Timer-iTimer
iTimer = Timer
For i = 0 to 50
Browser("index:=0").Page("index:=0").WebEdit("name:=q").Set i
Next
Print "Descriptive Programming = " & Timer-iTimer
3. OR via fixed reference variable (settings a variable to point to an OR object, and then using that variable).iTimer = Timer
Set oEdit = Browser("Google").Page("Google").WebEdit("q")
For i = 0 to 50
oEdit.Set i
Next
Print "OR via fixed reference = " & Timer-iTimer
Prashanth-QTP
iTimer = Timer
Set oEdit = Browser("index:=0").Page("index:=").WebEdit("name:=q")
For i = 0 to 50
oEdit.Set i
Next
Print "Descriptive programming via fixed reference = " & Timer-iTimer
5. Runtime through Object-Repository (using the object repository to access the WebEdit’s runtime object, and setting the value by changing a runtime property).
iTimer = Timer
For i = 0 to 50
Browser("Google").Page("Google").WebEdit("q").Object.value = i
Next
Print "Runtime through OR = " & Timer-iTimer
6. Runtime through Descriptive programming (similar to E).
iTimer = Timer
For i = 0 to 50
Browser("index:=0").Page("index:=0").WebEdit("name:=q").Object.Value = i
Next
Print "Runtime through Descriptive Programming = " & Timer-iTimer
7. Runtime through fixed object-repository reference (using the object-repository to get to the runtime object, inserting it into a variable, and using that variable)iTimer = Timer
Set oEdit = Browser("Google").Page("Google").WebEdit("q").Object
For i = 0 to 50
oEdit.value = i
Next
Print "Runtime through OR fixed reference = " & Timer-iTimer
8. Runtime through fixed descriptive-programming reference (similar to G).iTimer = Timer
Set oEdit = Browser("index:=0").Page("index:=0").WebEdit("name:=q").Object
For i = 0 to 50
oEdit.value = i
Next
Print "Runtime through DP fixed reference = " & Timer-iTimer
Prashanth-QTP
9. Runtime through the OR and GetElementByID
iTimer = Timer
Set we = Browser("B").Page("P").Object.getElementById( "id" )
For I = 0 To 50
We.Value = i
Next
Print "runtime through the OR and GetElementByID = " & Timer-iTImer
10. Runtime through the OR and GetElementByName
iTImer = Timer
Set we = Browser("B").Page("P").Object.getElementByName( "name" )
For I = 0 To 50
We.Value = i
Next
Print "runtime through the OR and GetElementByName = " & Timer-iTImer
The ResultsAnd here are the averaged results:
1)Regular OR = 5.59375
2)Descriptive Programming = 6.375
3)OR via fixed reference = 3.31253
4)Descriptive programming via fixed reference = 3.25122
5)Runtime through OR = 2.90625
6)Runtime through Descriptive Programming = 3.921875
7)Runtime through OR fixed reference = 0.203125
8)Runtime through DP fixed reference = 0.265625
9)Runtime through GetElementById = 0.20122
10) Runtime through GetElementByName = 0.21019
Prashanth-QTP
This turned up to pack some surprises, at least for me, but the bottom line remains the same – setting a variable to the GUI’s runtime objects is the most efficient method.
It seems that working directly through the object repository is faster than through descriptive programming (difference of almost a whole second – which quite shocked me, personally). This is reinforced by a more than a second gap when using OR and DP to access the WebEdit’s runtime object, however, the difference is wiped out by using a mediating variable.
It’s interesting to note that using the runtime object reduces the time by almost half, bringing it close to the performance of a fixed reference via a variable.
And the winner, by a full order of magnitude, is using the runtime object through a fixed reference variable. This is not surprising, as it avoids QTP’s GUI mapping mechanism completely (beside the first variable assignment).
Happy Automation
Prashanth-QTP
Thanks for Sharing Information to us. If Someone wants to know about QA and software testing this is the Right place for you...
ReplyDeleteSoftware Testing Services
Software Testing Services in India
Software Testing Companies in India
Software Testing Services in USA
Software Testing Companies in USA
Software Testing Companies
Software Testing Services Company
Software Testing Companies in New York
Independent Software Testing Services