Forum Discussion

msaunders's avatar
msaunders
Contributor
9 years ago

Python speed

I have found python to be extremely slow in test complete. I have created some timing tests iterating over arrays and doing actions with the array data.

I also wrote the exact same code and ran it in normal python command shell.

In test complete I am getting timing in the range of a few hundred ms all the way up to full second.

In command shell I am in the 1 ms range.

Are there any known issues with python and test complete? I am doing 0 interactions with my software's ui for this timing test as I wanted to rule out response time from my ui.

This all came about because tests just seem very show overall so going back to basics. I am using latest build of test complete.

I can share code snippets tomorrow when I am back in the office if that is necessary.

Thanks in advance for any feedback.
  • Support said this is just speed within the api and can't say much more. They said it has gotten faster over time so maybe will get better in the future but for now there is not much one can do to speed it up.

    We are going to move highs speed routines out of test complete for now as it seems like the better plan.

  • baxatob's avatar
    baxatob
    Community Hero

    Yes, you are right. Unfortunately Python scripts work slower than JS or VB (within TestComplete). However it became much faster from version 11 to 12. And I hope this trend will not be broken.

     

    At the same time I can excuse some lack of speed during the run-time, because with Python I have a very powerful tool during test development.

  • Support said this is just speed within the api and can't say much more. They said it has gotten faster over time so maybe will get better in the future but for now there is not much one can do to speed it up.

    We are going to move highs speed routines out of test complete for now as it seems like the better plan.

    • John_Laird's avatar
      John_Laird
      Contributor

      To add to this...you can certainly write a .NET DLL to do the heavy lifting (c# or whatever) and call its public methods from TestComplete (via CLR Bridge).

  • Attached is the script(had to make txt to attach) that I am using, just need to set the print to be log in TC.

     

    the output from TC is 360 and 858.

    Run in python shell the output is 1 and 1.

     

    This is shown in the second attachment image

     

    I will make a support ticket as this is using straight python nothing TC, it seems crazy that it is that much slower!

     

    This came up because it takes a really long time to run tests and the developers were asking me why.

     

    • baxatob's avatar
      baxatob
      Community Hero

      Don't forget that TestComplete needs a time to launch its own Python interpreter.
      In the case with the shell the interpreter is already launched.

  • Good point I think I accounted for that by having the timer only around the action not the entire function. Maybe python time.time does something I don't expect.

     

    I believe I am ignoring the 2-3 seconds it takes before the test even starts. I consider that time acceptable but iteration on an array to be almost 1 second seems pretty slow. 

     

    def test_timing():
        print("starting")
        start_num = time.time()
        numbers = create_permuted_ints(100)
        made_num = time.time()
        for i in range(50):
            for j in range(100):
                numbers[j] = (2 * numbers[j]) % 10000
        end_num = time.time()
        dt6 = int((made_num - start_num) * 1000)
        dt7 = int((end_num - start_num) * 1000)
        print(dt6)
        print(dt7)
        print("done")