It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red "F" in school...
I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: [email protected] Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + <some.number>' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 10000.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: [email protected] Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood <[EMAIL PROTECTED]> wrote on 13 Dec 2004 09:36:42 -0800 > I didn't include the delete statement because what you really wanted > to test was the LOOP/REPEAT vs. the GO construct. Guess what? After > doing four consecutive runs and picking the fastest of each four, > LOOP/REPEAT wins!!!!!! > ... > So does this end the GOTO holy war? > Less Filling, Tastes Better, Goes Faster??? > ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03: CTR = 0 04: ETIME = TIME() + 5 05: LOOP WHILE TIME() < ETIME DO 06: CTR += 1 07: REPEAT 08: PRINT "While ":CTR 09: * 10: CTR = 0 11: ETIME = TIME() + 5 12: 10 CTR += 1 13: IF TIME() < ETIME THEN GOTO 10 14: PRINT "Go To ":CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results ("W" indicates "Winner" :->) ------ Go To First ----- ------ While First ----- Go To Count While Count Go To Count While Count ----------- ----------- ----------- ----------- 769730 W 752380 667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I suspect there isn't a lot of difference. --Tom Pellitieri Century Equipment ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
