Forum Discussion

wmtan01's avatar
wmtan01
Contributor
5 years ago

Most efficient way to increment a value

Hi,

 

I was trying out different ways to increment an integer and noticed that the fastest way to increment an integer is to actually pass it to another script routine rather than actually using code snippets or code expressions to assign a value. Does anyone know why testcomplete works like this or if I'm missing something with how I make code expressions that's why it's taking longer?

 

Three ways tested:

  1. Using the Set Variable operation with Code Expression as the value
  2. Passing the variable and 1 to a script routine which would return the incremented value and set the variable to Last Result
  3. Using a Run Code Snippet operation and set the variable to Last Result

 

Here are the results:

Method 1 took 321s :smileyindifferent:

Method 2 took a mere 11s!!!!!

Method 3 took 324s :smileyindifferent:

 

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Honestly, don't know the answer to that in specifics.  I attempted the experiment myself and verified it is the case.  I suspect that it has to do with the different engines.  For Keyword tests, they need to call up a script engine to run the snippet or code expression where as the script routine uses an engine that is already present (at least, that's my understanding). 

    • Tienard1991's avatar
      Tienard1991
      Occasional Visitor

      tristaanogre wrote:

      Honestly, don't know the answer to that in specifics.  I attempted the experiment myself and verified it is the case.  I suspect that it has to do with the different engines.  For Keyword tests, they need to call up a script engine to run the snippet or code expression where as the script routine uses an engine that is already present (at least, that's my understanding) tellpopeyes.com


      Kudos. Really like this.