|
-
Jun 20th, 2007, 07:17 PM
#1
Confession of an Option Strict Convert
Back when I first got going with .NET, one of the first programs I wrote was actually a program I had written in VB6, then converted over to .NET (not using any wizard, it was a total re-design).
The program is a complicated genetic algorithm that does pattern matching. The number of generations is so high that the total runtime to reach an endpoint for all tests I performed with that original version took a minimum of three days, and some took a fourth day.
A couple days back, I decided to add a feature to the program, and as I was working on it, I realized that I was not getting warnings or errors when I should have. When I looked at the project settings I found out that I had not had Option Strict On for the project. Therefore, I turned it on, and took about an hour fixing the errors that arose. All but about two of them were really trivial cases of explicitly converting things that had previously been handled implicitly. The other two were bugs that I had never encountered, but which could have caused trouble at times (in fact, the program did cause unhandled errors once every week, or so, which was too rare and random to even attempt debugging).
Having made that change, I decided to re-run the program on the same data sets that I used the first time around. Since the time to completion changes each time, no single comparison is necessarily meaningful, unless the difference in runtime was HUGE Since the change I had made added a few minor steps, but added them at the innermost loop, so that they happened ALWAYS and OFTEN, I felt that the change would be a minor increase in time taken.
Now, the first run is nearing completion, and it will finish after only two days. Considering that ALL previous runs took AT LEAST three days, this is MUCH faster than any earlier run, even with the increased operations of the new feature (and running it for a few hours in a slower mode).
Therefore, it appears that Option Strict On does not just find some bugs, it can have a highly significant affect on the runtime of a code-intensive program. All of this speed increase appears to be due solely to explicitly directing casts instead of allowing them to be implicitly handled.
Use Option Strict at ALL times.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|