Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing coding speeds.

Status
Not open for further replies.

markSaunders

Programmer
Jun 23, 2000
196
GB
Is anyone aware of a resource/paper etc. that may be useful for highlighting some of the fastest methods to use when coding.

I find myself wondering such as...

what are the advantages (in terms of efficiency) in using the [tt]Select Case[/tt] v the [tt]IF/Then/Else[/tt] construct.
When does is make more sense to switch between the two?
Is the use of the [tt]OR[/tt] command more efficient in terms of speed as well as program run-time.
Which is faster - the [tt]While/DO[/dd] construct, the use of a Label: or some other looping mechanism?

just wondering anyways.... Mark Saunders :)
 
There was an article in VBPJ a couple of years ago about performance, but it mainly addressed things like using "with" statements to speed access to OLE properties.

I would say that the Select..Case would be faster than if.then.else constructs, since the various conditions in the select..case could be pre-calculated by the compiler, and not evaluated at run-time. I think the if..then..elseif..endif has to evaluate every condition every time, and would be slower.

The while..wend might be a little slower than using a goto..label:, but I think it will pay off in program maintainability. The only time I use a goto is when I need to bail-out of a deep set of nested control structures. IOW, much like a on.error.goto. But I haven't found a compelling need for using a goto in about 3 years. The do..loop, while..wend makes for much cleaner code, and is easier to figure out.

It might be an interesting experiment for you to test some of this out. I would suggest you use a timer control to see how many iterations each programming structure can run through in a 3 minute period. More iterations would mean faster performance.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top