GLBasic forum

Main forum => GLBasic - en => Topic started by: Wampus on 2011-Mar-08

Title: How much faster is INLINE?
Post by: Wampus on 2011-Mar-08
How much faster is INLINE for routines that won't need specialised GLBasic commands? Anyone written any code that could be used to compare?

Example of what I would try to use INLINE for: I have an A* pathfinding routine written in GLBasic. The GLBasic PATHFIND() is x2.8 times faster. Previously the speed my routine runs at wasn't an issue for what I was using it for but now I have a use for it that would benefit from as much optimisation as possible.
Title: Re: How much faster is INLINE?
Post by: Moebius on 2011-Mar-08
Remember that your GLBasic code ends up as C++, so unless you're using pointers to optimise things, I doubt that you could get a significant speed change.
I had to optimise creating, updating, and deleting particles held in an array, and I was able to get some more speed out of it, but only by using pointers to transfer values when deleting masses of particles from the front of the array.

I'm not sure what your routine looks like, but unless you can see areas of code where using pointers could aid in looping through arrays, from my experience, I doubt that you would be able to get much out of converting it to C++.
Title: Re: How much faster is INLINE?
Post by: hardyx on 2011-Mar-08
Inline code is faster, but GLBasic routines are optimized and your C code can be unoptimized. For example if you code a INLINE routine that is copying data in a loop, can be slowest than a pointer code.
Title: Re: How much faster is INLINE?
Post by: Wampus on 2011-Mar-08
Ah well. Thanks for the help & suggestions.

I've already altered the typical A* where I could using optimisations recommended in an article I found by someone who'd written an A* routine in C# (http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c12527__1/A-Star-A-Implementation-in-C-Path-Finding-PathFinder.htm).

Since my routine has to do more than FINDPATH() and looping through arrays has been greatly reduced or even substituted for faster methods entirely I don't know that INLINE would help much.
Title: Re: How much faster is INLINE?
Post by: Kitty Hello on 2011-Mar-09
The findpath algorithm I use is highly optimized. I doubt you can beat it easily.
Title: Re: How much faster is INLINE?
Post by: Wampus on 2011-Mar-09
Seems so. With 4 directions your algorithm is at least 2.8 times faster. If I increase directions to 8 or more I get figures like 3.6 times faster and upwards.