Defining Pet Features and Essentials

Ender Nafi Elekcioglu endernafi at keehuna.com
Thu Feb 13 04:13:03 EST 2014


Geoff,

I had no idea that benchmarking can be done in *nanosecond* level;
apparently, using *the long seconds*, it was possible.
Thanks for that.

However, as excellent code as your script is; 
I wasn’t trying to find the fastest recursive fibonacci algorithm
neither trying to find a solution for a technical problem.

It was a comparison of raw horsepowers of languages 
and discussing what we can do to see a far faster Livecode in the future.
It’s not a child task, I know.
Especially after reading your post:
> In a sense, applying memo might be considered a cheat, since the point was 
> that LC performance could be improved. Finding a clever way to patch over 
> LC's lack of tail-recursion optimization or memo isn't really the point, 
> but I thought it was valid here to mention that the thing that (I assume) 
> makes javascript faster than LC might be built-in on the JS side, but can 
> be replicated pretty simply on the LC side. 


In the light of these, I'm not sure that your comparison is fair.
I have used same algorithm both in C and Livecode
and the results were ~29ms. vs ~8seconds.
You can find them below.

I wonder what result will produce other languages using your array method.
We all know that there are tons of optimized fib algorithms which cut down the processing times in an order of magnitude;
to name a few: matrix, dynamic, space optimized, …


Again, the point is not getting the fastest results, rather comparing the results of exactly same algorithms.

Here are my test scripts for C and Livecode, respectively;
they’re pretty straightforward:

int fib(int n)
{
   if (n <= 1)
      return n;
   return fib(n-1) + fib(n-2);
}

-- 

function fib n
	if n <= 1 then
		return n
	else
		return fib(n-1) + fib(n-2)
	end if
end fib




~ Ender


More information about the use-livecode mailing list