On 17 Mar 2003, Henning Schmiedehausen wrote:

> On Fri, 2003-03-14 at 19:00, Alex Chaffee / Purple Technology wrote:
> > On Fri, Mar 14, 2003 at 12:34:56PM +0000, Henning P. Schmiedehausen wrote:
> > > Henri Yandell <[EMAIL PROTECTED]> writes:
> > >
> > > >Is there any reason why split/join are special?
> > >
> > > I need them. :-) And splitting at a single char / joining with a
> > > single char as delimiter is needed very often and using '.' is more
> > > efficient than "."
> >
> > I believe you, but I prefer clean interfaces to performance
> > optimizations.  If you run a quick performance test -- compare
> > splitting and joining, say, a 10-item and a 10000-item list both by
> > char and by String -- and post the results (or add them to the bug
> > report) it might help make your case.
>
>
> Without my patch:
>
> What                          10 items        10.000 item     100.000 item
> Iterations                    10000           100             100
>
> join(Object[], String sep)    91 millis       478 millis      13939 millis
> join(Iterator, String sep)    87 millis       977 millis      27737 millis
> join(Object[], null)          44 millis       518 millis      13628 millis
> join(Iterator, null)          74 millis       935 millis      22989 millis
>
> With my patch:
>
> What                          10 items        10.000 item     100.000 item
> Iterations                    10000           100             100
>
> join(Object[], String sep)    92 millis       480 millis      13801 millis
> join(Iterator, String sep)    87 millis       981 millis      27774 millis
> join(Object[], char sep)      40 millis       387 millis      13070 millis
> join(Iterator, char sep)      71 millis       931 millis      27114 millis
> join(Object[], null)          33 millis       337 millis      12498 millis
> join(Iterator, null)          61 millis       800 millis      21756 millis
>
> So the "char" operations are quite a bit faster especially with short array
> lengths. The join operation with null separator has been speeded up quite a
> bit (and concatenate() does map now on this).
>
> So please, apply the patch. :-)

+1 from me. While I'm against 'char'ing up StringUtils, the looping nature
of this method makes such a concession worth it.

Really though it makes me realise a limitation in Java, chars and Strings
ought to be replacable, with any String of 1 character being optimised to
a char. Ah well.

I'll wait for Alex to get his stuff in before applying your patch
[provided I can hunt it down, I'm finally getting out of my lethargy
towards coding].

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to