I guess you don't find it important until it takes a full second as opposed
and until the response time is important (performance).
I see no reason to stick SB wherever it possible. On the back-end - indeed,
but on client - arguably, till we have no the reason for this(like number of
string in cycle)
This is already atleast 10 times faster and can make a HUGE
difference in the running time of your app as this is a CPU bound task (it
uses 100% CPU on a CPU while doing this which means if you do this alot your
CPU usage will needlessly go up).
Sure, but it depends on type of app, whether it concerns us or not
Your code also only runs it once which completely ignores the GC penalty
incurred by the string methodology. Which my guess would make it closer to
15-20 times slower.
yes, but we haven't discuss how much it should be run
we just concatenate
strings
If we need to run in several times Strings are not appropriate
The penalty for using a SB is NEVER severe if used properly (unless you are
concating say 2 strings) .. the penalty is only severe for using strings ...
that is why it is best to error on the side of caution and use a
stringbuilder.
There I was talking about strings
mistyped.
I'm not arguing that Strings are good and "use String wherever it possible"
I want to say that the String isn't the evil as we discuss there
, but it
could be the evil if we dont understand how and where to use Strings or SB.
We need to see the app where OP use it, how and when.
What to say if we are struggling to save 1-2 seconds and then below in code
we could see the huge XSLT transformation that isn't optimized and takes 30
secs. Those saved 1-2 sec doesn't make any sense in this context
I've been reviewing code periodically, and have seen a lot of times that
people sticks SB even to concanting 2-3 strings, where you can use strings.
And this hasty using SB (because smbd have read somewhere that is very quick)
really influence on code readability. We are most read code rather then write
it.
Optimizing is for that have to be optimizing
--
WBR,
Michael Nemtsev :: blog:
http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche