Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease VB6 project startup time / Pinpointing what's taking so long

There are two vb6 applications that I work with. One of them starts up very quickly whereas the other one takes quite a long time. I thought I would do a little analysis to find out why the one takes so long.

So I hit F8 to start at the beginning and I realize that a significant portion of that startup time is actually between the time I hit F8 and the time it highlights the very first line of code.

Which of the following is most likely causing this?

  • Number of dependencies
  • Having too many projects in the group project instead of referencing them as dlls
  • Number of forms
  • Number of objects in the startup form
  • Number of objects on all forms
  • What else?

And as a bonus, I would love any ideas on how to more specifically pinpoint the problem if it could be in multiple areas.

Thanks!

Edit: It seems I may have not been clear enough on exactly 'where' the slowdown is occurring. So to make it clear I created the following procedure:

Sub Main()
End Sub

That's it, and it's in a module that contains absolutely nothing besides these two lines. No forms are getting loaded, and while there are other modules with "Dim o as New SomeObject", I know those objects aren't getting instantiated because I know that visual basic doesn't create objects declared this way until you actually use them for the first time.

I believe I have now optimized the startup code as much as is technically possible. Yet it still takes the same amount of time to startup.

Edit 2: I just realized that the compiled application actually starts up reasonably fast. It's just starting it in the ide that takes so long. However, I care a lot more about the speed for me than I do the customer cause they just start it once and leave it running all day whereas I start it a couple dozen times a day.

like image 778
Brandon Moore Avatar asked Nov 17 '11 22:11

Brandon Moore


2 Answers

That time is probably spent initializing all the objects on the startup form. Do you have a lot of COM objects or UserControls on the startup form? They may, in turn, load other objects that they are using.

The best way to debug this is to remove one object at a time (don't worry about built-in controls, just worry about external objects) from the startup form until you figure out which one is taking the most time at startup. You can then try to speed up the launch time by optimizing the startup code in that object, or at least by deferring the creation of that object until it's actually needed.

like image 179
Joel Spolsky Avatar answered Nov 15 '22 21:11

Joel Spolsky


How big is the project? It's probably doing an intermediate compile to p-code so it can run it. You may be able to tweak this using the Compile settings in the Options dialog.

like image 31
Deanna Avatar answered Nov 15 '22 20:11

Deanna