Hi, I've noticed that Mike did a commit that enables the ARM/Android
port of LuaJIT2, and I was impatient to test it out on my (slow+cheap)
Pulse U8220 phone [1].
The compilation of LuaJIT2 was very straightforward, using the Android
NDK and the instructions given at doc/install.html
To compare it, I also compiled the standard Lua interpreter for Android.
In order to do that, I had to patch llex.c / trydecpoint and remove the
decpoint tricks [2], because locale support is missing from Android.
Then I modified the src/Makefile, modified the PLATS variable to include
"android" and added the following rule:
android:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN $(NDKF)"
MYLDFLAGS="$(NDKF)" MYLIBS="-Wl,-E -ldl"
Then, I ran make using the same variables as for the LuaJIT build:
make CC="${NDKP}gcc" AR="${NDKP}ar rcu" RANLIB="${NDKP}ranlib"
NDKF="$NDKF" android
I compared the performance using scimark.lua [3], and here are the
results:
# lua -v
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
# time lua scimark.lua
Lua SciMark 2010-12-10 based on SciMark 2.0a. Copyright (C) 2006-2010
Mike Pall.
FFT 0.34 [1024]
SOR 0.78 [100]
MC 0.22
SPARSE 0.44 [1000, 5000]
LU 0.53 [100]
SciMark 0.46 [small problem sizes]
# luajit -v
LuaJIT 2.0.0-beta6 -- Copyright (C) 2005-2011 Mike Pall.
http://luajit.org/
# time luajit scimark.lua
Lua SciMark 2010-12-10 based on SciMark 2.0a. Copyright (C) 2006-2010
Mike Pall.
FFT 1.63 [1024]
SOR 4.38 [100]
MC 1.07
SPARSE 2.58 [1000, 5000]
LU 3.43 [100]
SciMark 2.62 [small problem sizes]
It looks like LuaJIT is 5x times faster than standard Lua on my phone
(if I understand the results correctly). For comparison, on my Core i3
M350 laptop I get a SciMark score of 12.55 for Lua, and 588.47 for
LuaJIT, so the difference is not as big, but it definitely is great to
have LuaJIT running on Android :)
[1] http://wiki.modaco.com/index.php/Huawei_U8220
[2] http://www.lua.org/source/5.1/llex.c.html#trydecpoint
[3] http://luajit.org/download/scimark.lua