News for hackers. Stuff that matters.
Re:Lua: Good, bad, and ugly parts by graue on Saturday March 09, 2013 @03:21PM (#5349497)
I documented the tests on my project log:

https://scott.mn/projects/luasynth.html#filter_effect

In short, I ran C and Lua implementations of the same command, 6 times each, using the built-in "time" command in bash. Averaged the "user" time for each implementation and compared the results. As input, I used a 2m:38.040s long song, 44.1 KHz stereo, converted to a raw file with 32-bit float samples, and I redirected output to /dev/null.

For the first benchmark[1], which was faster for LuaJIT, I actually messed up: I compared the "real" time rather than the user CPU time. But as I recall, the "user" times bore the same relationship, and there was very little deviation among the six trials. If you don't trust me, feel free to do a more rigorous test!

It's worth mentioning that the effect for which LuaJIT beat C was a simple gain, so what was really being tested was a loop that multiplied a bunch of numbers by a (within the loop) constant. The second test in which Lua was a factor of two slower may be more representative.

To build the code, clone the graue/synth and graue/luasynth repos on GitHub. synth includes build instructions, while Luasynth merely requires you to install LuaJIT and run the script.

[1]: https://scott.mn/projects/luasynth.html#lua_beats_c

Re:Lua: Good, bad, and ugly parts by azakai on Saturday March 09, 2013 @03:35PM (#5349540)
Thanks!