VC Loop Speed!
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Omni

Okay, I've always thought there was some kind of overhead for VC loops. Which makes stuff like:

While loop


while not done

draw pixel


So slow. But...what if there was no loop?

Recursion


void MyFunc()

{
if done
return
draw pixel
MyFunc
}


Would Recusion be MUCH faster? As in fast enough to make too impractical VC loops to be worthwhile?

Posted on 2004-06-30 14:54:03

Zip

I'm almost certain that function calls are one of the slowest things in verge. Loops, asingments and conditionals are all reasonably quick.
I'd say the slow thing in that code is the SetPixel() - which you can't get round really.

Zip

Posted on 2004-06-30 15:19:19

Omni

Function calls are one of the slowest things in verge...

Whoa, what? Seriously?

Posted on 2004-06-30 15:56:41

Zip

Hmm... I was slightly misleading there. CallFunction("") is slow, a blank function call void Func(void) is actually quite fast, it's passing and returning that's slower - and then only significantly in relation to the same thing done in code. Thats how my alternative abs() is faster.

So I tried to give you code a go, but verge didn't like it - compiles but kicks out with no crash and no error message. Here's the code, just in case I'm being a moron:
void Recur()

{
if (x > 1024 * 1024) return;
x++;
Recur();
}

With x as a global and a call to Recur(); between my timing stuff.

Zip

Posted on 2004-06-30 17:15:25 (last edited on 2004-06-30 17:15:26)

Zip

McGrue, did my post just auto edit itself to fix the fact I had a > rather than >?
In case it works again, that a plain greater than sign, than a & gt;

Zip

Posted on 2004-06-30 17:17:38

Omni

X was a global variable, right?

It is also possible that VC has a limit to how deep the threaded functions can go.

Posted on 2004-06-30 18:01:44

vecna

Uh.. yeah. Eventualy you'll run out of stack space. 1million nested function calls is definitely bigger than the VC stack allocation. ^_^

Posted on 2004-06-30 22:21:13

Omni

Hmm. Thought I had a good idea that time. Darn.

Posted on 2004-07-01 01:27:48


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.