What You Don’t Know Hurts You

Whether you use native code or p-code, you probably want your code to be as fast as possible. You wouldn’t have picked this book otherwise. Of course, it doesn’t make sense to optimize every statement. If you have a trade-off between speed and size, or between speed and reliability, or between speed and some other factor, you might not always choose speed. But you always want to understand the trade-offs, and you don’t want to write code that is unnecessarily slow when there is no trade-off.

But what’s faster? You can guess how Basic works and try to think through which techniques might be faster, but how can you know for sure? There’s only one answer. You have to time it. But timing code in a multitasking operating system is difficult and inconsistent. Let’s summarize what you don’t know about Visual Basic timing:

A lot of variables come into play, but one thing is clear: to find the most efficient way of performing an operation, you need to test it multiple times.