How to use full potential of StringBuilder in UiPath

How to get the speed of StringBuilder in UiPath.

In the below code everything works fine. str is of type StringBuilder. It take 20 seconds to finish the loop.

BUT, if I change the type of the variable to str to String and instead of using Invoke Code, if I simply use Assign like str = str+“abcd”. It also takes 20 seconds to complete.

I know StringBuilder is much faster. I do some research in console application. That took only 2 seconds to complete loop of 10000 in StringBuilder.

What is the catch in UiPath then ?


Welcome to UiPath community!

When you’re trying with console application using visual studio it will be faster only since it is in the native script with native IDE.

But here in UiPath everything need to be parsed to continue with the actual operation, that’s why it is taking time.

Hello @rramakrishnan
In addition to what @sarathi125 said, please be aware that if you are only looping a hundred times the performance benefit will be very small. The + operator uses StringBuilder internally. When the code compiles there is slightly more overhead time but over 100 loops you won’t notice it. Especially if you’re only doing that one append.