This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Speeding up method searches


Per Bothner wrote:
> There is a tradeoff here: A binary search will use fewer comparisons
> than a linear search on interned strings, but the cost of each
> comparison is much cheaper in the latter case, since you don't need
> to look at a single character.

Especially when you consider cache behavior.  The binary search is far
more likely to generate cache misses.  Linear searches can perform
remarkably well on today's >500MHz processors.

Some benchmarks might be worthwhile.  I have some Java wrapper code for
the x86 counter (rdtsc) lying somewhere around here if anybody is
interested...

-- 
Jeff Sturm
jsturm@sigma6.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]