Which of the following is faster
-
Which of the following is faster : 1. if drRows.Length then end if 2. if drrows.length > 0 then end if 3. if Cbool(drrows.length) then end if Any Suggestions? Thanks
-
Which of the following is faster : 1. if drRows.Length then end if 2. if drrows.length > 0 then end if 3. if Cbool(drrows.length) then end if Any Suggestions? Thanks
-
Which of the following is faster : 1. if drRows.Length then end if 2. if drrows.length > 0 then end if 3. if Cbool(drrows.length) then end if Any Suggestions? Thanks
Yeah..it would be easy to test. My guess it #1 is the fastest. All three are doing drRows.length but #2 and #3 are both doing an additional operation. "Half this game is ninety percent mental." - Yogi Berra
-
Which of the following is faster : 1. if drRows.Length then end if 2. if drrows.length > 0 then end if 3. if Cbool(drrows.length) then end if Any Suggestions? Thanks
My suggestion (and dare I say the 'correct' way) is to use (#2) because you are comparing "apples with apples" and not forcing an implicit (#1) or explicit (#3) type conversion. The conversion may cause problems in the future and there is no guarantee that (#1) for example will evaluate to Boolean, nor (#3) evaluate to False when the value is zero. ...Steve "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once :-)
-
Which of the following is faster : 1. if drRows.Length then end if 2. if drrows.length > 0 then end if 3. if Cbool(drrows.length) then end if Any Suggestions? Thanks
Thanks Briga, dotnethead, and Steve for your replies. As suggested by briga, i ran a test program with loop of 9999999. When i run the test about many times, each time the result was different. Some times Case #1,#2,#3 all took same time, at times #1 was the fastest, at times #2 , another time #3 and at other times there was a tie b/w the cases. so could not reach a conclusion. As Steve pointed out [it was the reason i posted the question] #1 involves an implicit type conversion [integer is converted to boolean], #2 a comparison and #3 an explicit type conversion, it is difficult to say which would run faster. After much thought i too reached the conclusion that #2 is better [it atleast explains the code better] Thanks every one