• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Perfomance Issue with Tree Loading (using ArrayList)

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have an application wherein we have 2 frames.

Left frame has a tree-like structure and the Right frame has the details of the selected node (just as in windows folders)

On the right frame, apart from the details ,there are a set of buttons which are of two kinds:
(a)Buttons used to manipulate tree nodes itself like 'Add Node', 'Delete
Node'(Tree state changes) Basically tree must be refreshed from DB to
show the changed state
(b)Buttons used to manipulate the node details (Tree state remains the same)

Issues:
In case of say 30 nodes its fine but beyond that if the nodes are say 100 in number, then the page takes a lot of time to load(more than 8 seconds).

Also, when the tree refresh happens (in case of (a) above) it's even more slow.....(more than 12 seconds)

Right now I am using an arrayList for node population(We chose arrayList as out of about 18 functionalities, in only 3 - add/move/delete node, the tree state gets refreshed, otherwise for rest of the 15 functionalities
the tree state remains the same)

Is there a better collection that may render better performance ?
How may I address the performance issue?

Regards,
Amit
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you allocate the memory for the ArrayList? Did you try allocating a big chunk upfront?. How exactly do you process Add/Delete of nodes? If you are processing from scratch then you can think about operations like retaining the existing ArrayList minus deleted node or adding the new node. If you can paste the code it will help..
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ArrayList operations are VERY fast, I'm sure your problem lies elsewhere. You might want to do some profiling, for instance with JAmon - (free).
Bill
 
amit bose
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually did not allocate any memory before populating the ArrayList.

I would do the following:
Given that I would have about 500 elements in the ArrayList,
I would require to initialize with 500 elements before populating arrayList.

Please let me know if any other tuning is possible?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To use the Texas vernacular "you are barking up the wrong tree" - any process taking more than a few milliseconds is NOT being held up by the operation of ArrayList functions.
Perhaps your code is redrawing the screen after every addition - that can chew up some time, but my money is on ANY database operation.
RIGHT NOW, before doing anything else! Go get JAMon and instrument your program to see whats really taking the time.
Bill
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post the same question to more than one forum; see our explanation here. I've deleted the other copy of this thread in JiG(Advanced.)

As Mr. Brogden says, go figure out where the time is actually going, before you try to optimize! It's silly to waste time speculating when you could instead be measuring.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic