Four Js Development Tools Forum

General => Ask Reuben => Topic started by: Reuben B. on July 09, 2020, 02:13:25 am



Title: Ask Reuben 37 - Large Strings
Post by: Reuben B. on July 09, 2020, 02:13:25 am
In the previous Ask Reuben article I discussed how STRING should be preferred over the use of CHAR variables of some arbitrary length and one of the reasons given was performance.  This performance advantage is most noticeable when manipulating large strings. 

Any time you are constructing a large string you should consider using the base.StringBuffer class and its append method as it makes the most of passing by reference.   

How can you verify this gain?   What you can do is create a little test program that has different functions using the various data types and techniques available to construct a large string, and then use the “profiler" to measure what percentage time is spent in each function.  You can then infer that the test function that has the least amount of percentage time spent in it has the datatypes and techniques with the best performance.

This article has such a test program and shows how to interpret the test results and conclude that base.StringBuffer and the append method has the best performance when constructing a large string.

Read more at https://4js.com/ask-reuben/ig-37/