R
Richard Lewis Haggard
I thought that the whole point of StringBuilder was that it was supposed to
be a faster way of building strings than string. However, I just put
together a simple little application to do a comparative analysis between
the two and, surprisingly, string seems to out perform StringBuilder by a
significant amount. A string concatenation takes not quite twice as long
using StringBuilder than it does with a string. This doesn't sound right to
me. Does anyone else have any hard performance data experience on the
subject?
Here's what I did- I made a simple little app that starts two worker
threads, one uses string to concatenate string and the other uses
StringBuilder. Once a second, each of the worker threads reports the number
of concatenations it has performed to the UI which displays them. The string
thread generally runs at 3 million a second. The StringBuilder turns in
about 1.8 million. Does this run counter or agree with your experience?
be a faster way of building strings than string. However, I just put
together a simple little application to do a comparative analysis between
the two and, surprisingly, string seems to out perform StringBuilder by a
significant amount. A string concatenation takes not quite twice as long
using StringBuilder than it does with a string. This doesn't sound right to
me. Does anyone else have any hard performance data experience on the
subject?
Here's what I did- I made a simple little app that starts two worker
threads, one uses string to concatenate string and the other uses
StringBuilder. Once a second, each of the worker threads reports the number
of concatenations it has performed to the UI which displays them. The string
thread generally runs at 3 million a second. The StringBuilder turns in
about 1.8 million. Does this run counter or agree with your experience?