X-Received: by 10.66.190.104 with SMTP id gp8mr837884pac.9.1362001320777; Wed, 27 Feb 2013 13:42:00 -0800 (PST) X-Received: by 10.50.33.175 with SMTP id s15mr2713135igi.8.1362001320545; Wed, 27 Feb 2013 13:42:00 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!su1no14506167pbb.0!news-out.google.com!jm3ni23191pbb.0!nntp.google.com!su1no14506153pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Wed, 27 Feb 2013 13:42:00 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <1rcs4eq420jj8.3menl13xfrpv.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <89669b41-7a35-434e-90cd-57f7342ee70b@googlegroups.com> Subject: Re: FastCat 'performance' From: Lew Injection-Date: Wed, 27 Feb 2013 21:42:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 3619 Xref: csiph.com comp.lang.java.programmer:22597 Daniel Pitts wrote: > Jan Burse wrote: > > Joerg Meier schrieb: >>> So, FastCat is doing even worse if .toString() is used. And much, much >>> worse if .toString() is used more than once. >>> > >> Ok, so then. Thanks. > > Now, to be fair to Roedy, you aren't exactly using it "as proscribed", > and you aren't testing the time spent in the constructors. > > I've made the Strings you append longer, and I've fixed the estimates > for the FastCat and the StringBu*ers constructors to be spot-on: > > Fresh SB/FCs: > Cat> Init: 00.000ms, Loop: 00.175ms, End: 00.000ms, Total: 00.175ms. > Buf> Init: 00.000ms, Loop: 00.227ms, End: 00.000ms, Total: 00.227ms. > Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms. > Reused SB/FCs: > > Cat> Init: 00.000ms, Loop: 00.023ms, End: 00.375ms, Total: 00.398ms. > Buf> Init: 00.101ms, Loop: 00.048ms, End: 00.130ms, Total: 00.279ms. > Bui> Init: 00.092ms, Loop: 00.052ms, End: 00.130ms, Total: 00.274ms. > > For Fresh, Init/End do nothing, but toString() is called every loop. > > For Reused, Init creates the buffer/builder/fastcat, and End is the > single call to toString(). > > If I remove the estimate entirely from StringBu*er constructors, FastCat > does indeed win out. FastCat relies on a "good estimate" to start with, > so I left that estimate in. > > Fresh SB/FCs: > Cat> Init: 00.000ms, Loop: 00.187ms, End: 00.000ms, Total: 00.187ms. > Buf> Init: 00.000ms, Loop: 00.240ms, End: 00.000ms, Total: 00.240ms. > Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms. > > Reused SB/FCs: > Cat> Init: 00.000ms, Loop: 00.020ms, End: 00.377ms, Total: 00.397ms. > Buf> Init: 00.000ms, Loop: 00.495ms, End: 00.122ms, Total: 00.617ms. > Bui> Init: 00.000ms, Loop: 00.468ms, End: 00.121ms, Total: 00.589ms. > > So, depending on its use, FastCat *can* be about twice as fast as > StringBuffer/StringBuilder. It can, however, be significantly slower as > you have shown. How does it compare to using String +? How does it change after a 10,000-loop warmup to kick in HotSpot? > Sorry Roedy, I'm not going to switch to FastCat any time soon. It's not > a bad idea for a specialized use-case, but as a general use-case not as > good. -- Lew