Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.awt.container.add(comp) bottleneck
    primarykey
    data
    text
    <p>I am updating/maintaining an existing graphing program. This is suppose to be a medium duty program (able to handle anything less than a million nodes + their transitions). In the GUI, there is a 'viewport' that visually shows the graph and there is a side panel that contains tabs that contain summaries on the nodes, transitions, etc...</p> <p>The graphical part works phenominal and is quick but after running a profiler (YourKit) 96-99.8% of the time is spent creating the summary tab/table for the nodes. So for 10,000 nodes, it takes a second or two to generate the graph visually but minutes for it to populate the table!</p> <p>A summary of the process is this: the tab gets notified that the model changed and gets the node list. If it needs more rows, it adds them, else it reuses or throws old ones away. Then after creating the rows and their cells, it fills them.</p> <p>The population is one node per row, three cells (JPanel) per row (each contain some information). Each time a cell is created when a new row is added or the row is asked to check for updates, it calls the "positionPanel" method provided below. The layout manager is SpringLayout. According to the profiler, of the 90-odd percent to generate this table, 90-odd percent minus one is the "add(newPanel);" line.</p> <p>Any suggestions on where the speed is being taken and how to improve it? </p> <pre><code>private void positionPanel(int row, int col) { JPanel upPanel = this; JPanel leftPanel = this; String upSpring = SpringLayout.NORTH; String leftSpring = SpringLayout.WEST; if (row != 0) { upPanel = cells.get(row - 1)[col]; upSpring = SpringLayout.SOUTH; } if (col != 0) { leftPanel = cells.get(row)[col-1]; leftSpring = SpringLayout.EAST; } Cell newPanel = cells.get(row)[col]; //cells.get(row).set(col, newPanel); add(newPanel); layout.putConstraint(SpringLayout.NORTH, newPanel, cellSpacing, upSpring, upPanel); layout.putConstraint(SpringLayout.WEST, newPanel, cellSpacing, leftSpring, leftPanel); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload