This is more for information rather than a question. (Forgive me if this information is recorded elsewhere, but I couldn't find it.)
I did a simple trial on the order of WHEN statements in a CASE...ENDCASE clause.
Code: Select all
T% = TIME
FOR I% = 1 TO 10000000
A% = 1 : REM set this to 10 for a second run
CASE A% OF
WHEN 1:
WHEN 2:
WHEN 3:
WHEN 4:
WHEN 5:
WHEN 6:
WHEN 7:
WHEN 8:
WHEN 9:
WHEN 10:
ENDCASE
NEXT
U% = TIME
PRINT U%-T%
The results (on my computer) are that when A% is set to 1 it takes 1510ms to run (151ns each loop), and when it's set to 10 it takes 4820ms to run (482ns each loop). Calculation suggests that each WHEN line will take an additional 37ns, approx. This may not seem much to the average programmer, but it may well add up if there are a lot of loops and CASE clauses.
Please feel free to add anything to this, or correct me if I'm wrong.
Matt