First, do the obvious.  Well, if it is obvious, why mention it here?

1.  Use the fastest PC you can afford.

2.  Add as much memory as you can afford.

3.  Use as fast a hard drive as you can afford.

4.  Use as fast a video card as you can afford.

5.  Minimize the use of other applications (multitasking).  If other applications must be used, make sure that they already are loaded before you start your time-critical process, and allow time for Windows to finish all of the memory management tasks associated with loading these other applications before you start up the D/A process.

Now, for some less obvious suggestions.

1.  Remove and device drivers that are not necessary for the operation of your computer.  For example, network cards (and their associated drivers) can impair the performance of the PC significantly, especially if there is significant network traffic.  Even if network traffic is light, performance is reduced.  If you don't need it, don't use it!.  Use the Control Panel/Network icon to remove the network bindings, and remove the actual hardware.

You can extend this suggestion to removing any other hardware and drivers that are not needed, though the efficacy of other removals will be less obvious than the network.

2.  If your application uses ActiveX, it should be "in-process", not "out-of-process," if possible.  So, if you use OLE (automation) to activate an Excel spreadsheet, or an Access database, you will gain significant speed improvements by moving these tasks to code that executes within your own application.  Likewise, if you can use an ActiveX DLL instead of an ActiveX EXE to perform some specific task, your application performance will improve measurably.

3.  You can gain some small performance improvements by using several API techniques.  

Multiple threads can improve performance.  However, multi-threading in Visual Basic varies from tricky to... impossible.  I suggest that you wait for language improvements before you try multi-threading.  Also, multithreading improves performance best in systems with multiple processors (Windows NT or Windows 2000), and this is not a common environment.

You can use the SetPriorityClass API function to increase the multitasking priority that Windows applies to your application.  The SetPriorityClass function allows you to set a priority of "Normal," "High" or "Real-time." (and others, but these are the three that are important for this discussion).  "Normal" priority is the default priority that Windows assigns to your application, and is what you should use when not executing time-critical processes.  You can set this to "High" to allow your process to preempt all other processes that have "Normal" priority.  You should use care when assigning a "High" priority to an application -- other "Normal" applications will become quite sluggish -- none-the-less, they will continue to execute.  You also may set priority to "Real-time."  This will cause your process to preempt all "Normal" and any "High" priority processes.  This is dangerous, but will give your process the maximum time-slice.  The effect of its use will be to suspend most other processes, so you should make sure that you return your process priority to either "Normal" or "High" as soon as the time-critical processing has finished.  

You can download a simple Visual Basic 6.0 demonstration application that I have created to illustrate the use of the SetPriorityClass API function.  Click here.  You may freely use this code in your applications.  If you find benefit from it, let me know (any favorable attribution would be appreciated).  

To see the affect of SetPriorityClass, run the example code while loading another application (the one that I like is Word).  When "Normal," the other application will load at the speed that you expect, if set to "High," the other application will load very slowly, and other operations would be equally slow.  If set to "Real-time," the other application will not load -- in fact, you probably cannot even select it in Explorer, or by using a Shortcut!

 

Send mail to dick_grier@hotmail.com with questions or comments about this web site.
Last modified: 11/25/09
Hit Counter