Mar. 11th, 2005

juan_gandhi: (Default)
Another benchmark. I decided to check, which List implementation is "better". The code (boring) is at the bottom, under cut.

<th><td>Vector</td><td>ArrayList</td><td>LinkedList</td></th>

add
188.9 128.2 234.3
        list.clear();
        for (int i = 0; i < size * 2; i++) {
          list.add(null);
        }

set
33.0 54.5 2681.4
          for (int i = 0; i < size; i++) {
            list.set(i, value);
          }

get
84.3 103.1 5495.5
        int n = list.size();
        for (int i = 0; i < n; i++) {
          x = list.get(i);
        }

rnd
256.2 313.8 5947.1
        int n = list.size();
        for (int i = 0; i < n; i++) {
          x = list.get((int)((i * 317l) % n));
        }

lst
228.0 187.4 104.9
        for (Iterator i = list.iterator(); i.hasNext();) {
          x = i.next();
        }


</td></tr>
</table>

I ran it on JVM 1.4.2, Windows 2000, 2Gig memory, some 2.6Gig processor.


Now, the code (boring)
Read more... )

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
171819 20212223
2425 2627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 27th, 2025 06:46 am
Powered by Dreamwidth Studios