[jdom-interest] About JDOM performance
phil at triloggroup.com
phil at triloggroup.com
Tue May 22 15:03:55 PDT 2001
Alex,
In your test, I saw 3 pitfalls:
1/ the code inside the loop is itself costly and has itself a cost significantly greater that the list manipulation =>
you're calling twice the Math.random() and you're allocating an object, which is precisely why a linked list is slow.
2/ you're using the System.currentTimeMillis() which is not a way to measure time precisely.
3/ the global test only take 120ms which, compared to the currentTimeMillis() precision, is really two small.
Finally, have a look at another simple test I uploaded
(http://lists.denveronline.net/lists/jdom-interest/2001-May/006595.html), eventually execute it and saw the profiler
state. I attached the JProbe result and you'll see the great difference.
About memory consumsion, you may know that a single object has an overhead of ~30 bytes (depending on the JVM and the
OS). A list entry is then about 30+12 bytes=42 bytes. Now think about you're 100,000 items list and you'll have an idea
of the memory eaten.
The last point concern the garbage collector. As these object are temporary (like a graphical Rectangle or a
Dimension...), they are moved by HotSpot from the "nursery" to the classical heap. This completly slows down the garbage
collector.
I spent my last week-end trying to determine how I can optimize JDOM. My app is running in a servlet and cannot take so
much memory without swapping and slowing down the web server.
Phil.
More information about the jdom-interest
mailing list