Computational Speed Issue:Text output from ZeroTouch

I am creating a node which display text output . I realized the computation speed slows down a lot when the output are texts with numbers (StringBuilder ) compare to just number output (List). May i know how to solve this issue ?

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

Code samples would help too.
I’d start by telling us how you timed the computation. If you haven’t and it’s perceived only, start there :slight_smile:

Also, strings vs ints/floats can take up a different number of bytes in memory, so strings will likely be slower : https://www.tutorialspoint.com/cprogramming/c_data_types.htm

2 Likes

Quoting from many Stack Overflow posts about this same issue:

If your pattern looks like:

x = f1(…) + f2(…) + f3(…) + f4(…)

that’s one concat and it’s zippy, StringBuilder probably won’t help.

If your pattern looks like:

if (…) x += f1(…)
if (…) x += f2(…)
if (…) x += f3(…)
if (…) x += f4(…)

then you probably want StringBuilder.

Here’s a few resources on how to optimize string building.


In general there is .NET speed issue of concatenating large strings, but there is also the ELEPHANT in the room issue of Dynamo preview. As you have noticed Dynamo generates output preview bubbles below each node. If that is a list of large number of elements, or some long strings etc. IT WILL SLOW DOWN your definition considerably. Keep in mind that it’s generating these previews for all nodes in the definition. That’s a lot of string building that Dynamo is doing by itself already.

Devs are aware of that issue, as far as I know.

Cheers!