Page 1 of 1 1
Topic Options
#156597 - 2006-02-04 12:50 AM General Question about KiX Loops
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Has anyone done any stress/performance tests on KiX loops where they found that one runs more efficiently than another? I know in PHP some loops are better for certain kinds of data so I'm just curious from an optimization stand-point..

- Do Until
- While Loop
- For Next

Top
#156598 - 2006-02-04 01:27 AM Re: General Question about KiX Loops
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It would very much depend on the complexity of the conditional expression that it is looping on. I would think a For Next loop would be the simplest.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156599 - 2006-02-06 10:07 AM Re: General Question about KiX Loops
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You could have answered your own question by writing a simple benchmark

Code:
Break ON
$iIterations=999999
$aLoops="For $$i=1 to $iIterations Next",
"While $$i<$iIterations $$i=$$i+1 Loop",
"Do $$i=$$i+1 until $$i=$iIterations"

For Each $sLoop in $aLoops
"Benchmarking "+Split($sLoop)[0]+@CRLF
$iStart=@TICKS
$i=0
$=Execute($sLoop)
$iEnd=@TICKS
"Start: "+$iStart+@CRLF
" End: "+$iEnd+@CRLF+@CRLF
" Time: "+(CInt($iEnd)-CInt($iStart))+" ms"+@CRLF+@CRLF
Next

Exit 0


Top
#156600 - 2006-02-07 12:11 AM Re: General Question about KiX Loops
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
yeah but i'm a noob and know that i could've ran timed loops but i also wanted to know if any of the 'old hats' had done this and had data out there. i wasn't asking someone to do it, just if it HAD been done for informational purposes...
Top
#156601 - 2006-02-07 12:55 AM Re: General Question about KiX Loops
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
As I said, "It would very much depend on the complexity of the conditional expression" so it is very much like asking "how long is a piece of string".
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156602 - 2006-02-07 09:24 AM Re: General Question about KiX Loops
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
les is right here.
say, you have a do loop (or while loop):
Code:

do
$line = readline(1)
until @error



trying to fit that into for loop is not that easy.
thus, all of the loopers have a task they are good in.
depending on the task, one might be slightly or largely better than other.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.084 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org