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!

IF IF or IF AND 1

Status
Not open for further replies.

dbomrrsm

Programmer
Feb 20, 2004
1,709
GB
Very quick question:

What would be more efficient:

Code:
IF var_a = var_b THEN
	IF var_c = 101 THEN

Do something......

	END IF;
END IF;

OR

Code:
IF var_a = var_b AND var_c = 101 THEN

Do something......

END IF;

Or would there be very little difference ?

TIA


[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 
The first one will fail if a != b and not test the second condition, so behaviourly they are the same.

As Santa Mufasa says, one test is worth a hundred expert opinions. Put them both in a loop which counts from 1 to a million and run a comparison. I think you will struggle to detect any difference at all.
 
Dagon

You were completely correct - a 100 million loop cycle took 87.8 seconds using IF IF and the same took 87.93 seconds for an IF AND.

[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top