Re: Found a case where slower than plain lua

  • From: Sean Conner <sean@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 18 Mar 2015 16:15:41 -0400

It was thus said that the Great Daurnimator once stated:
> On 18 March 2015 at 15:46, Sean Conner <sean@xxxxxxxxxx> wrote:
> >   What happens if you replace the calls to math.random() with a constant?
> 
> Something very odd, it got worse:
>    - lua5.1: 4.280025
>    - lua5.2: 4.691467
>    - lua5.3: 3.467526
>    - luajit-2.0.3: 18.524167
>    - luajit-2.1.0-alpha: 18.47558
> 
> 
> -- bench.lua
> local new_fifo = require "fifo"
> local f = new_fifo()
> 
> local t = os.clock()
> for j=1, 50000 do
>     for i=1, 103 do
>         f:push(1)
>     end
>     for i=1, 100 do
>         f:pop()
>     end
> end
> print(os.clock()-t)

  Okay, I looked up os.clock() and for Lua 5.1, 5.2 and 5.3, the description
is the same:

        Returns an approximation of the amount in seconds of CPU time used
        by the program.

So what could be happening here is that LuaJIT is hitting the CPU harder
than PUC Lua, and what you are seeing the amount of CPU time being used; not
wall time. What gets reported when you run "time lua-whatever bench.lua"?

  -spc

Other related posts: