« Return to Thread: Which performs best: C loop calling short Io or Io loop calling short C routine?

Re: Which performs best: C loop calling short Io or Io loop calling short C routine?

by Steve Dekorte :: Rate this Message:

Reply to Author | View in Thread


On 2009-06-14, at 9:10 AM, dennisf486 wrote:

> If I did this then the Io code wouldn't run out of a callback;  
> instead it would look like this:
>
> cursor := Cursor clone
> while (cursor hasBoxes,
>   DisplayOpenGLCube(cursor next_box)
> )
>
> Now it's just an Io routine calling a C routine (next_box) over and  
> over.  The C routine should be fairly fast, but I will have to do a  
> lot of work to make it maintain its place in the datastructure on a  
> custom stack object, instead of implicitly remembering where it was  
> using recursive functions as it does now.
>
> So my question is, is the second version likely to perform better  
> than the first version, and is it worth doing?

If the number of iterations is high, then you'd probably want to put  
the cursor enumeration bit in C - something like:

cursor := Cursor clone
cursor display // display is a C function which will handle the loop  
in C

 « Return to Thread: Which performs best: C loop calling short Io or Io loop calling short C routine?