One thing which is seldom asked about these timing tests is; does it make any real difference?
Part of the answer to that question requires a definition of ‘real difference’, yet how many times do we see ‘real difference’ defined?
Windows is interactive with people, it is event driven. If people do not notice the difference then is the difference real? Sure we can time it to the millisecond but will they notice it?
Consider feedback to the user via the screen. The screen may only update every 16 or 20 milliseconds because it is governed by screen refresh rate and that is, generally, governed by mains frequency 60/50 Hertz. So in the unnoticeable time of the screen refresh, a CPU, running at a one nanosecond clock speed, has performed at least 16 million clock cycles. Even if the data bus is running 10 times slower than the CPU clock that still amounts to 1.6 million memory accesses which go unnoticed by the user.
In the article by Ken it is stated that every little bit counts; but does it really?
An example from some years ago:-
It was asked on this site; what is the fastest way to write to a Text Box on a Form?
Eight methods were put forward as to how to do it. The test indicated that there was less that about 20% difference between the eight methods. The real surprise was that by turning off screen echo all the times were about 1800% faster.
Another aspect is when it stated that smaller code does not necessarily run faster.
I’ll go further and say… generally speaking, the larger the code the faster it will run.
As almost always there is a caveat here: we must assume that both sets of code for testing are written with the same degree of functionality.
We start with the understanding that the fastest code of all is the code that is seldom executed.
We add more testing code to determine if the slow bulk of code really needs running. We add an If statement based on a Boolean expression on a single line of code. If that If statement is True we then move to the next inner If statement in a second test of increasing complexity, and so forth. We do not combine all tests on the one line because they will all need to be evaluated. So, by increasing the size of the code, we evaluate if the slow bulk of code really needs to be executed. And we do that by starting with the fastest outer test and progressing to the most complex inner test.
-----------
The tests by Ken are still valid but we now have to ask; are the results still real?
They are VBA verses VBA tests and under most circumstances today, I think not.
I think that every little bit counts actually counts for very little.
Chris.