Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to trim load time of application

Status
Not open for further replies.

JavelinMan

Technical User
Jul 10, 2001
15
US
Hey there,
I'm working on an application built in SunOne4 rebuilt from Symantec Cafe. on SuSe7-linux (Intel 1.7Ghz with 512DDR) it loads in 2 seconds on average; the 900Mhz/128SDRAM w/XP runs average 5 seconds; the 367Mhz/128 w/98SE runs 10 seconds, and my boss's laptop (XP & PIII i think) takes 15 seconds to load the GUI.
The good news is once it's up it's very quick and responsive. The bad news is my boss can't figure out what to do with himself for 15 seconds, so I'm under the gun.
I have put time tags thoughout the initiation method (2228 lines). I have located a spot (35 lines) in the code that seems to take 40% of the time lag, but upon inspection there does not seem to be much there that could account for the time consumption, I am at a complete loss.
If anyone has an idea or needs more info, let me know.

Thanks in advance
ZRJ
 
are you creating lots of panels, buttons, etc. in advance? You could use lazy instantiation on some things....

e.g.

JPanel buttonPanel = null;

public JPanel getButtonPanel(){
if (buttonPanel==null) buttonPanel = new JPanel();
return buttonPanel;
}

This will spread the creation of objects throughout the time the gui is used and subequently make it less responsive at first.

Alternatively, you could create the objects that are required to start work then create the rest of the objects in a background thread...slightly trickier. Jeremy Nicholson, Director of a UK-based Java and Data Warehousing consultancy
 
That's what I was thinking, here are the 35 lines::

//35 lines that take almost 40% of load time
lTimeValue111112 = new java.util.Date().getTime();
Newfc = new javax.swing.JFileChooser();
Openfc = new javax.swing.JFileChooser();
Savefc = new javax.swing.JFileChooser();
Copyfc = new javax.swing.JFileChooser();
ErrorPanel = new javax.swing.JPanel();
ErrorScrollPane = new javax.swing.JScrollPane();
errMessage = new javax.swing.JTextArea();
LDDPanel = new javax.swing.JPanel();
LDDTabPane = new javax.swing.JTabbedPane();
BrowsePanel = new javax.swing.JPanel();
ETable = new javax.swing.JLabel();
NTable = new javax.swing.JLabel();
STable = new javax.swing.JLabel();
WTable = new javax.swing.JLabel();
tableScroller = new javax.swing.JScrollPane();
TableSorter sorter = new TableSorter(tm);
multiList = new javax.swing.JTable();
sorter.addMouseListenerToHeaderInTable(multiList);
FieldPanel = new javax.swing.JPanel();
DataName = new javax.swing.JPanel();
ConstDNLabel = new javax.swing.JLabel();
datanameTextField = new javax.swing.JTextField();
LddTabs = new javax.swing.JTabbedPane();
 
Ok, a couple of tips that may improve your loadup time.
1) Dont create the JFileChooser objects until they are needed. This will mean the program will run a little slow at these points, but will load faster to being with.

2) Unless you are actually manipulating the ScrollPane you can create it where it is needed eg.
Code:
ErrorPanel.add(new JScrollPane(***))
(replacing *** with your component to appear in the scrollpane).

The reason for the slow down is obviously the object creation, which is the most expensive (processor wise) operation you have in java.

In which case, looking at the above code, you best bet would be to create the objects you vitally need straight away, and then farm the others out to be created in the background.

Either that, or give your boss a plastic slide puzzle to play with while its loading. ;-)
-------------------------------------------
There are no onions, only magic
-------------------------------------------
 
Check your java implementation. On some AIX versions, you can use -X faststart or something like that. This is not portable, because the -X stuff is implementation dependant, but it may work for your distro.
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
I will relocate the fileChoosers and retest, and then reply, Thanks
 
Thanks guys! Removing the fileChoosers to where they are needed really sped up the show. Thanks again for the successful response!
 
Im glad it helped JavelinMan. -------------------------------------------
There are no onions, only magic
-------------------------------------------
 
Hi JavelinMan:

I saw a TableSorter in your code, I suposse that you take it from the JTable demo of the JDK (for the addMouseListenerToHeaderInTable method...). Be careful with that component (that is excellent) because it makes huge processor consuming sorter tasks, so if you have a large amount of data it could take long.

Hope it helps. Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top