rvirding/luerl — pull request #20 by lastcanal (2013-02-21 06:07:33+00:00)
Title: Benchmark Suite

Hi Robert, I have put together a runner for the Lua benchmark suite 'Luamarca'. The benchmarks are runing without issue except for 2.

[inf.lua](https://github.com/lastcanal/luerl/blob/benchmark/examples/benchmark/suites/inf.lua) is throwing the 'illegal number' error. The illegal number just so happens to be `infinity`. C-Lua is returning `inf` instead of throwing an error. `1/0` is also apparently `inf` according to C-Lua and not a `badarith` as is currently thrown by luerl.

[mtvsclosure.lua](https://github.com/lastcanal/luerl/blob/benchmark/examples/benchmark/suites/mtvsclosure.lua) is throwing an `illegal index` error when attempting to call a meta-method on a metatable. I'm not sure why.

I also ran into an issue when running `luerl:decode/1` with a table ref that had a lua defined function in it. I'll put together an example for you. I have worked around it by running a lua script to return the keys from the global state. A bit of a hack but it works!

The benchmarks scripts work by setting a global table named `bench` where the keys are the benchmark names and values are the benchmark functions. The runner will iterate over each key in the `bench` table and execute the functions using `luerl:method1/3`. Currently you can override the default number of iterations per suite by assigning a number to the global variable `NUM_ITERATIONS` from within the Lua script. This number will take precedence over `?DEFAULT_ITER` as defined in benchmark.erl.

I also had to add the method `loadstring` to luerl_basic as it is used by the a couple of the benchmarks. It's in a separate commit if you need to cherry pick it.

Here is the output of the benchmark from my laptop: https://gist.github.com/lastcanal/5002524