I would be deeply suspicious of benchmarks that naive, especially for benchmarks like this that involve lots of allocation -- you're most likely benchmarking the GC, not the actual operation.
On Tue, Apr 2, 2013 at 3:33 PM, Ivan Gerasimov <ivan.gerasi...@oracle.com>wrote: > > On 03.04.2013 1:17, Martin Buchholz wrote: > >> Have you benchmarked the case where the element is never present? >> > That's the only case I've tested. > If the element were in the array, my code would obviously win. > > > (with the usual caveats about micro-benchmarking - perhaps use google >> caliper?) >> > The tests I wrote are quite simple - they just run a code snippet for > several hundreds of times. > I've just sent and archive with the tests in reply to the other message in > the thread. > > > >> On Tue, Apr 2, 2013 at 2:11 PM, Ivan Gerasimov >> <ivan.gerasi...@oracle.com<mailto: >> ivan.gerasimov@oracle.**com <ivan.gerasi...@oracle.com>>> wrote: >> >> >> I've done a little testing on my side. >> I used Integer as an underlying type and set length of the array >> to the values from 1 to 100. >> My code shows a little performance gain - approximately 9%. >> I understand it may not be there for all cases, but at least for >> some cases it is there. >> >> > -- Louis Wasserman