Performance: New Functions between old style coding...

Started by Darkknight900

Darkknight900 Lv 1

I just added 2 recipes for some benchmark tests.

I just want to point out again that these functions are really useful in some complex ways where we need to use more code without them BUT the benchmarks show that these functions are really slow… Test yourself… increase iterations when you don't see any differences…

I just wanted to point this out because we need to resolve this performance issue.

And surely the functions are in some way slower but i dont think that they are that slow…

Btw. i just want to optimize my recipes so the real working functions can be used as much as possible.

Darkknight900 Lv 1

Tried again and i think there weren't any performance improvements done…

Can someone explain why we should use them or are they for some special operations needed? To my mind these functions are just useless because we can do the same work with other code faster.

Also sorting table can be done faster with some more code than with the ipair iteration…

brow42 Lv 1

Since ipairs is identical to for 1,# (it even stops at the first nil) I never use this. I do use pairs and there is no good replacement for this (I'd need a second table of keys).

I always use table.sort for sorting unless I know I only have values 1-N with no holes.

difftime seems poorly conceived by the Lua designers. There seems to be no portable way to a time difference in seconds. Fortunately, it seems the implementation dependent os.time returns seconds on all common platforms.