Testing VB Code Speed

From VbGORE Visual Basic Online RPG Engine

(Redirected from Testing VB code speed)

This project is for those who want to know which routine is faster of two. This is a great way to check if one chunk of code is faster then another, and if your optimizations are being of use.

Note that this uses high priority thread (can be turned off). It is reccomended not to, and will be hard to, do anything else while this is running!


Version 1.1

Released on March 8, 2007

Contains a very critical fix resulting in Test2 always being slightly faster

SpeedTemplate.zip (3.67 KB)

Writing The Code

Adding the routines to test is very simple. There is a TestOne and TestTwo module, with a TestOne and TestTwo sub. Simply just place the code you want to test in TestOne and the code you want to compair it to in TestTwo, or vise versa. Make sure you compile before running.


This will run in high-priority to ensure results are as accurate as possible. It is recommended you compile your project the exact same as you would the project you are using this code you are testing is for.

For most accurate results, do the following:

- Iteration number high enough to test for about 2-3 minutes

- Run after restarting your computer

- Run in compiled mode with the same compiling options as you will be using it under

- Run as very few applications in the background as possible (remove as much as you can from the task manager with Ctrl Alt Del)

- Do not even touch your mouse or keyboard until the test is complete

Side Notes

Please keep in mind that with small pieces of code with little difference, you will not see very great results. You may see -50% in one case, then 100% on the next result. This means that the change is negligible and you should treat them as equal. In this case, you will want to go with whatever method uses less memory if you are really wanting to optimize your routine.

Personal tools