lua-users home
lua-l archive

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


skaller wrote:
> It isn't. Its faster. I just measured it at twice as fast,
> but the reality is much better, C++ is almost certainly
> 100 times faster than C. The reason is obvious why this
> must be so: setjump stores lots of registers in a memory
> buffer to establish a handler. C++ probably pushes a single
> pointer on the stack. C++ is the clear winner.

Wait ... we were talking about throwing and not just catching.
Throwing is where C++ is slow (and this was the only thing I claimed
in my original remark in the docs).

For catching alone the differences are minimal (~3% on my platform) and
there is no clear winner, depending on how you measure. You get a
doubling, I don't (but I measured including the overhead of a Lua script).

For catching + throwing (1:1 ratio) C++ is around 40 times slower than C
(on my machine).

I guess one difference is that 'catch' may be inlined, whereas 'setjmp'
may not. C++ frame unwinding is highly compiler- and ABI-specific, so
making comparisons across platforms is unlikely to yield (ha!) useful

And again: relevant _only_ if you throw tons of errors, not if you
just want to catch them.

[sorry, for yet another off-topic post]