Re: Hash or Tree
Wojtek wrote:
Wojtek wrote :
BUT, I could place each key during the loading process into an
ArrayList, then when done create an array from it, then run through
the array and set the index value into the LangKey. Then use that
index value to directly access the array to get the value.
Ok, did the changes and ran 5 identical tests for each category. I hit 7
pages with 989 lokkups. And....
HashMap - average of 3,356 nano seconds
Array Lookup - average of 2,370 nano seconds
So there is a 33% reduction in lookup time.
Or else the test didn't run long enough relative to the
frequency of the underlying clock you timed it with. The
fact that it's possible to *express* your height in ?ngstr?ms
(1E-10 m, 0.1 nm) doesn't mean your height can actually be
*measured* with that kind of accuracy; a clock that *reports*
a value in nanosecond units may actually be *measuring* in
milliseconds or centiseconds -- or fortnights.
If you can determine the number of "fundamental clock ticks"
that underlie the measurements, you can get an idea of whether
the observed difference is meaningful. For example, if the clock
ticked 300 times in the first experiment and 200 times in the
second, the ratio of times is (300 ? 1) / (200 ? 1), which is
somewhere between 299 / 201 ~= 1.49 and 301 / 199 ~= 1.51, so
your "33% reduction" is fairly solid. But if the tick counts
are 3 and 2, all you can say is that the time ratio is between
(3 - 1) / (2 + 1) ~= 0.67 and (3 + 1) / (2 - 1) = 4: You don't
even know which is faster, never mind by how much!
--
Eric.Sosman@sun.com