Micro Focus QTP (UFT) Forums
Drawbacks of using too many function calls? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Drawbacks of using too many function calls? (/Thread-Drawbacks-of-using-too-many-function-calls)



Drawbacks of using too many function calls? - vishwas.shenoy - 02-13-2013

We are creating QTP scripts to validate the UI screen elements (presence, weblist contents, checkboxes, etc). I had created a function called "validateObjects" and saved it in the library file (.vbs). I was calling this function in my script by passing the object properties as parameters (we following DP).
The function will verify the presence of the objects on the screen and report pass or fail accordingly.

As expected, the number of function calls were too many in the script. For each UI element i had inserted the function call.

Our client manager is not happy with the script. He is saying it will bring down the QTP performance. When asked how, he informed us to find out by ourselves. I googled for the information. But no luck so far.

for the busy-experts, here is one liner question - "Will the QTP script take more time to execute when a lot of function calls are present in the script? If Yes, how?"


RE: Drawbacks of using too many function calls? - basanth27 - 02-14-2013

I would say performance is affected. When you call a function there is a hit on the memory QTP utilizes. You call multiple functions and then heap of memory is under consideration. This affects performance in turn slows down the execution if memory management is not performed well.

I wouldnt say if you write a 1000 functions, the performance is hit. It would matter if you had not released the objects you create accordingly. Moreover, optimization is what is required for you.
Say, you have 100 objects on the screen. When you begin, if you write one function which creates all of the objects and you have operation to be performed only on say 10 objects. In this case, all of the 100 objects are first initalized and then operation on 10 objects is performed. Isint it useless to create 90 more objects? So, break it down. Create multiple functions for each of the screen attributes you have. For eg: IF you are automating Gmail, you create objects for Inbox in a function and then sent mail in a different function or probably New email objects in one function and so on and so forth. This way you can optimize and cause a less hit on the memory and improve the performance.