I need speedy code and splitting hairs is necessary.

Iketh

Active member
Joined
Nov 23, 2009
Messages
40
Programming Experience
Beginner
I'm making a program whose speed needs to be the absolute fastest or users simply won't use it. I have a TON of examples I'm not 100% sure about. Ill start with this one.

Is it quicker to:

A) set a boolean->make a double-precision calculation->read the boolean and continue with code

or

B) make a double-precision calculation->see if the calculation is > 0 and continue with code

I want to assume B because it's not making an additional write to memory, but on the other hand it's handling a double-precision number twice...
 
Last edited:
Use a stopwatch and try both!
VB.NET:
Dim sw As New Stopwatch
sw.Start
'your code here
Debug.WriteLine(sw.ElapsedMilliseconds)
 
if speed is of the essence then you really shouldn't be using VB.NET in the first place. VB.NET is about speed of development, not speed of execution. It relies on the fact modern hardware is fast and most apps sit around waiting for user input most of the time. If speed is critical then you really should be writing all or part of your app in some other language. C# can have an advantage in some situations because it supports pointers natively. Beyond that, unmanaged C++ is what most people use for performance-critical apps. You can include inline assembly code in C++ or write pure asm if you want even better perfromance.
 
thanks jmcil, but why does my other question keep getting deleted?
It's been managed by a moderator. Make use of your profile page. It will show you where your threads are.
 
Back
Top