> True. Sorry I made an error on calculations.
> However I can confirm that doing the test on the compiled application
> instead of running in the IDE, if-then and select-case perform at nearly the
> same.
>
> Massimo Valle
I decided to run my own test on the Case vs. If-Else times.
I wrote a program that populated an array(1000) with random numbers from
0-100. Then it ran an 10,000 interaction empty loop just reading the numbers
out of the array. Then a 10,000 interaction loop with 100 case statements.
Finally a similar loop with if-else statements. Timing was done by using the
microseconds function. The empty loop times were subtracted from the total
loop times and this was all averaged 10 times.
Running under the debugger I got a whopping 11-12X difference with the case
being slower (60,000us vs. 5,000us). When I built the application under
Mach-0 the iteration times dropped dramatically on the case loop and the
difference dropped to 12% (4200us vs. 3700us). Unless I was going to always
run under debugger, I think the difference is insignificant, and given the
less typing required to do case statements, I'll use case.
With the 100 statement loops the code is a bit cumbersome to post here, but
if anyone would like to critique it I'll be happy to send it along.
Michael
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|