lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 31/08/2011 10.17, Alexander Gladysh wrote:
On Wed, Aug 31, 2011 at 11:03, Lorenzo Donati
<>  wrote:

I stumbled a funny result when doing very simple benchmarking on some of my

You did not say if you were using plain Lua or LuaJIT. Seems to be plain Lua.

Yes, sorry. You are right. Plain Lua.

According to the following benchmarks, built-in math.floor and math.ceil are
slower than their counterpart rewritten using the core % operator!

That is to be expected. C function call is relatively slow.

Do you mean that floor and ceil are really slower?

What's the point of including them in the library then? I assumed they were at least slightly optimized.

I agree that they are more readable, but since they are really easy to replace with a one liner using %, shouldn't they fall under the "useless fat" principle of Lua - If you can do them yourself easily and they would be even faster, why not removing them? Wasn't those the reasons that led to log10 removal in 5.2?

Am I missing something?


thanks for the feedback.

-- Lorenzo