Hi Mike,

On 12/10/2011 10:05 AM, Mike Skells wrote:
<snip>
The majority of the CPu reduction comes from removing the creation of
implicit StringBuilders and their resizing

Patrick - this is why you idea doesn't really provide the answer, there
is still a StringBuilder created for each line of stack trace printed,
and probably a resize as the line is probably > 16 chars, as well as 2
writes for each line

Ah I see. I missed the key point that you now use a single SB across the entire process of printing the stacktrace. I guess my only additional comment on that is that it would seem to be be a good idea to increase the initial size of that single SB as it is likely to grow on its very first use.

Also a minor gain might be had to change println(sb) to be println(sb.toString()) and avoid the String.valueOf intermediate call (and null check).

Aside: can't help but feel that the streams should directly support CharSequences so that we don't need to convert to intermediate Strings.


Cheers,
David

Reply via email to