🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
2 messages
2 total messages Started by Welf Wustlich Mon, 15 Aug 2005 13:48
Performance problems with jdk 1.5 on Linux plattform
#420
Author: Welf Wustlich
Date: Mon, 15 Aug 2005 13:48
18 lines
1506 bytes
Performance problems with jdk 1.5 on Linux plattform
(not tested on Windows, might be the same)

After refactoring using the new features from java 1.5 I lost
performance significantly:


public Vector<unit> units;

The new code:
         for (unit u: units) u.accumulate();

runs more than 30% slower than the old code:
         for (int i = 0; i < units.size(); i++) 
units.elementAt(i).accumulate();

I expected the opposite.
Is there any information available that helps?
Re: Performance problems with jdk 1.5 on Linux plattform
#422
Author: Shankar Unni
Date: Mon, 15 Aug 2005 21:14
20 lines
1774 bytes
Welf Wustlich wrote:

> public Vector<unit> units;

Using an arraylist helps slightly.

I got some fairly anomalous results comparing ArrayList and Vector: for 
the 1.5-style loops, ArrayList was faster then Vector, but for a loop 
with get() calls, Vector was faster. Vector was even faster than that 
using elementAt(), which was a surprise:

For a million summing iterations over a 100-element array:

vector elementAt loop took 3446 ms.
vector get loop took 3796 ms.
vector iterator loop took 5469 ms.
arraylist get loop took 4136 ms.
arraylist iterator loop took 4668 ms.

Really odd, and educational.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads