[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is it supposed to be faster to call a C function than a Lua function when in Lua?
- From: Eric Wing <ewmailing@...>
- Date: Thu, 27 Jun 2013 13:00:04 -0700
> If you look at the c code of the Lua interpreter, this is not really
> surprising. There is not really a language bridge at that point. The Lua
> interpreter is in C as well. All it does is a call of a C function pointer.
>
So just as an additional data point, I've been looking at
JavaScriptCore and v8 which are also implemented in C/C++.
(JavaScriptCore's JIT is disabled since I am testing it on iOS, while
I'm doing v8 on Android which cannot disable JIT).
In both cases, calling to C from Javascript was more expensive than
calling C from Lua. In JSCore, the Javascript empty function call was
faster than calling the C empty function, but both were slower than
Lua calling a Lua function.
In v8, the empty Javascript function call was much faster, about 10x
faster than the C call and about 5x faster than Lua. But I think I'm
more surprised that v8's JIT didn't completely optimize out the loop
and empty function and make the time 0.
Thanks,
Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/