|
-
Nov 9th, 2000, 10:14 PM
#1
Thread Starter
Addicted Member
Well, my app takes too long to load. It's a commercial app, so I was hoping to make it as fast as possible, but it takes an annoying 11 sec on my P3/450 mhz/128 MB Machine -- and is depressingly slower on average machines. Woe is me. This is the first app I ever wrote, and everything works great except for this one problem.
Sure, I've got a splash screen with a progress bar, but the problem is that it takes many seconds for my main form to even get to the Form_Load event(after calling Load Form). The splash screen just sits there for a while before the progress bar starts to actually move.
The main form is control-rich (many textboxes & datagrids on SStabs) so I guess it's taking a long time to load it all into memory. Total size of .exe is 344KB. I cannot remove any controls from the form, as product launch is ASAP and there's no time to redo the user interface.
I've tried:
1. Trying both P-Code and native code compiling
2. Trying to optimize for size vs speed
3. Using a compression program to reduce the size of my .exe even further
4. Converting all ADODC's to simple ADO recordsets
5. Loading ALL graphic resources at runtime only
6. Removing all other forms from the project
7. I even went so far as to replace all standard buttons and textboxes with windowless versions to reduce resource usage.
Result: NO improvement, not even 1 or 2 seconds faster!!! 
Before I call it quits, I thought I'd ask you guys for any suggestions, in case there's something I missed. Thanks for reading this long post.
-
Nov 9th, 2000, 10:30 PM
#2
Frenzied Member
Is it just this app? Other stuff doesn't take a long time too? I mean, maybe the HDD could do with a defrag, or other general PC cleanup stuff. *Shrugs* just a thought.
Harry.
"From one thing, know ten thousand things."
-
Nov 9th, 2000, 11:09 PM
#3
A couple of suggestions:
1) If you have a significant amount of code behind your main form, move that code to a module.
2) Do a trace and see if you are loading other forms that you don't immediately need. You may know this already, but a form will be loaded if you refer to any of it's visible controls. If you are doing that either directly or indirectly in the load of your main form, you can avoid it by creating properties in your other forms and changing the code in the main form to refer to the other form's PropertyLet's. You can then load the other form when it's needed, and refer to the PropertyGet's for the properties you previously set.
-
Nov 10th, 2000, 12:39 AM
#4
Thread Starter
Addicted Member
Guys,
Thanks for your responses. I ran Norton SpeedDisk & Cleanup on my system, and also tried moving a lot of code from my main form into a module. I checked and no other forms are referenced at loading.
Unfortunately these measures had no effect on loading time. I'm still open to any new suggestions, I'm ready to try anything.
-
Nov 10th, 2000, 05:25 AM
#5
Just a suggestion...
Rebuild your project completly...
-
Nov 10th, 2000, 06:17 AM
#6
transcendental analytic
I have to say i'm almost with kayoca, rebuild it! 
But well you could do some more tests first.
1. Send me a screeshot of your mainform, so that i can see which controls are useless.
2. Check *** is taking so long. Trace all procedures you have at program startaup, place breaks and if needed you could step(F8) trough the most important procedures. Then next step is to place "debug.print gettickcount-start" everywhere after each single process you are suspicious about, until you get the exact time of each procedure, then you write down the times, and what it does, and post it up here, then maybe we could give you some help 
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 10th, 2000, 08:08 AM
#7
- Check for loops that are unnecesary long
- Check of some events are fired several times during startup
- Open datafiles etc. on an on-demand basis (1)
- Sort, Compress and swap stuff on an on-demand basis (1)
- Use Native code
- Don't compress the exe. It'll take time to de-compress!
- Try using Integers & Longs instead of Singles and Doubles where possible
- Cache often-accessed object properties in variables
- Remove unused code
- etc...
- (1) Don't use all the data at once, but in tiny bites...(not bytes ...)
Hope this helps...
Enjoy!
-
Nov 10th, 2000, 09:12 AM
#8
Fanatic Member
My first app had the same problems, though I found out what was causing them. Alot of my problems were dealing with listviews/treeviews being populated and visible at the same time. This caused major loading problems. My suggestions:
1) Do not populate any controls with data and have them visible at the same time. Make them visible = false until after they are populated.
2) I also found that if you need to populate a treeview that you can increase loading times by assinging everything to arrays during startup, then when the program is up and running, populate the tree. I had an array for each major branch and only populated that first level + 1 sub level of the tree. This allowed quick execution. When the tree was expanded, I added the rest then.
3) Loading anything directly to a listview is rather slow, place it in an array during load and then populate the list when it becomes visible.
4) Place all of your controls in a Picturebox or Frame on your main form. Then, during form load, have the frame's visible property = false. After load, make it visible.
5) If you have alot of 'like controls' that do just about the same thing, think about putting them into a control array, this should speed things up just a wee bit.
6) I found the other day that explicitly accessing the default property/method of a control will slow it down a little bit (text1.text, file1.filename, etc.). Try referencing these controls with just the control name (text1, file1, etc.) which, I've been told, will help speed up the code a little.
7) If you use alot of if then statements in long succession and you're testing for one result, or using if then ... elseif ... else if ... etc. Try replacing that with a case statement. IIF() also works well if you need to make a quick choice match.
8) If you have collections or other items that can work with For Each control structures and you're using For Next control structures (for each control in controls, for x = 0 to ubound(controls)) use the for each statement instead. It's a bit faster.
9) If you have alot of global variables and some of them aren't even used in more than one sub/function/property, etc. then declare them local to the sub/function/property, this will not only save on memory, but should improve speed a little.
10) If you are loading alot of things during the 'about dialog display phase', examine what's going on in that form. Apply any of the above tips to this form as well.
Hope this helps in your optimization quest.
-
Nov 10th, 2000, 12:41 PM
#9
Thread Starter
Addicted Member
Thanks for the replies. It has greatly stimulated my thinking, which is just what I need right now. Let me clarify my situation a bit further:
It only takes about 2.5-3 seconds for my form to execute its loading statements.
BUT -- it's taking about 6-8 seconds for my form to start loading (executing), after I start running my app. The total time varies randomly from 9 to 12 seconds. If I close the app and immediately run it again, it only takes the 2.5-3 seconds, probably because Windows still has the form cached in memory. First time run is always slow, however.
ExcaliburZone - I used the idea of hiding my controls on the form until after the form had loaded -- and it looks like I reduced loading time by about 2 seconds! Thanks for your thoughtful reply.
I'm still going to work on it some more, so if anyone has anymore ideas at all, I am willing to listen!
-
Nov 10th, 2000, 02:27 PM
#10
Thread Starter
Addicted Member
After more experimenting, I think what's slowing down my form load is not the amount of controls on my form, but connecting to my database (.mdb using ADO). That's what causing the program to "hang" for a few seconds before the rest of the form starts loading.
Since there's no way to make that any faster, I think that pretty much ends that. However, using some of the suggestions all of you gave me, I have been able to finally reduce the "apparent" form loading speed by 3-4 seconds.
I found that by placing the code that opens the database in the Form_Initialize event instead of Form_Load, I get a speed increase (don't know why). I also use DoEvents to display the form as fast as possible and doing some of the loading in the background.
I think with a little more efficient coding, I may be able to shave off another second or two. Thanks for all the input from everybody!
-
Nov 10th, 2000, 03:12 PM
#11
Member
I've also read (on this site i believe) that if your doing DB access and your loop condition is an
Code:
Do While rst.eof = False
Loop
that the EOF check takes even longer than retrieving the data itself, so you can ususally speed it by chaging this to a
Code:
For i = 1 to rst.Recordcount
next i
type of loop (i know thats DAO not ADO but just for sake of argument...) may speed it up considerably during your mdb access hang.
[Edited by glitch13 on 11-10-2000 at 03:14 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|