YourBestNightmare Posted June 18, 2015 Author Share Posted June 18, 2015 I was bored (and that means really really bored) so I decided to do something usefull (finally).There is only one "working" and popular library for Java that embeds and interprets Lua, called **LuaJ** (which is **rewrite of entire Lua VM in Java**). I did some benchmarks, and gosh, it is slow. So I decided to write something by myself.First, I looked at other well-know (but broken) library for Java called **LuaJava**. This had a bit better performance, because it was linking **native Lua to Java via JNI**. So I forked it and started working.First, I needed to learn how to fucking cross-compile with C and C++. Wasn´t that hard. Then, how to compile LuaJIT. This was hard. After I finished everything, only thing what left was to join it everything together through JNI.And voila, **60x better performance than LuaJ**.Here are some benchmarks comparing native Lua 5.2, LuaJ and Nonlua (my implementation):```--------------------Lua 5.2 - richards_loop.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.300267--------------------LuaJ 3.0 - richards_loop.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.637--------------------nonlua - richards_loop.lua--------------------Benchmark starting Starting finished qpkt count = 23246 holdcount = 9297 these results are correct end of run Time: 0,029677 --------------------Lua 5.2 - richards_oo_loop.lua--------------------0.317031--------------------LuaJ 3.0 - richards_oo_loop.lua--------------------0.795--------------------nonlua - richards_oo_loop.lua--------------------0,042081 --------------------Lua 5.2 - richards_oo_meta.lua--------------------0.347223--------------------LuaJ 3.0 - richards_oo_meta.lua--------------------1.198--------------------nonlua - richards_oo_meta.lua--------------------0,071686 --------------------Lua 5.2 - richards_oo_meta_cache.lua--------------------0.347799--------------------LuaJ 3.0 - richards_oo_meta_cache.lua--------------------0.989--------------------nonlua - richards_oo_meta_cache.lua--------------------0,075797 --------------------Lua 5.2 - richards_oo_meta_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.344058--------------------LuaJ 3.0 - richards_oo_meta_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 1.405--------------------nonlua - richards_oo_meta_tail.lua--------------------Benchmark starting Starting finished qpkt count = 23246 holdcount = 9297 these results are correct end of run Time: 0,066472 --------------------Lua 5.2 - richards_oo_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.299772--------------------LuaJ 3.0 - richards_oo_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.816--------------------nonlua - richards_oo_tail.lua--------------------Benchmark starting Starting finished qpkt count = 23246 holdcount = 9297 these results are correct end of run Time: 0,037498 --------------------Lua 5.2 - richards_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.298897--------------------LuaJ 3.0 - richards_tail.lua--------------------Benchmark startingStartingfinishedqpkt count = 23246 holdcount = 9297these results are correctend of runTime: 0.69--------------------nonlua - richards_tail.lua--------------------Benchmark starting Starting finished qpkt count = 23246 holdcount = 9297 these results are correct end of run Time: 0,032288 --------------------Lua 5.2 - scimark.lua--------------------FFT 2.67 [1024]SOR 5.59 [100]MC 1.63 SPARSE 3.11 [1000, 5000]LU 3.77 [100]SciMark 3.36 [small problem sizes]--------------------LuaJ 3.0 - scimark.lua--------------------FFT 1.9138876404494385 [1024]SOR 4.284102447353442 [100]MC 1.8526077738515876 SPARSE 2.6364572605561274 [1000, 5000]LU 3.156752490875014 [100]SciMark 2.768761522617122 [small problem sizes]--------------------nonlua - scimark.lua--------------------FFT 75,89 [1024]SOR 298,13 [100]MC 53,07 SPARSE 72,13 [1000, 5000]LU 154,97 [100]SciMark 130,84 [small problem sizes]``` Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now