lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Thought I'd try a performance test. I'm using this function:
> 
> function mklist(n,tail)
> 
> For 1000 iterations of lists length 1000, lua 5.0.2 gives
> 
> time = 9.6 seconds
> memory used before major collection = 479K
> 
> Work4 gives:
> 
> time = 10.89 sec
> memory = 1698

I get the following on an Athlon 64 3200+ running Windows XP:

luarc: 2.37 secs, 1,449,984 peak
lua-5.0.2: 3.02 secs, 1,847,296 peak
lua-5.1-work4: 4.07 secs, 4,358,144 peak

> This test is a bit unfair, because there is no persistent 
> global data so I changed it to this:
> 
> for i = 1,iters do
>   local j = i
>   if j > 100 then j = 0 end
>   master[j]=mklist(listlen,nil)
> end
> 
> For 100 element lists, 1000 iterations,
> the Work4 collector is the same speed as the 5.0.2 one, and 
> it uses 10% less memory.

iters = 1000, listlen = 100

luarc: 0.25 secs, 2,981,888 peak
lua-5.0.2: 0.36 secs, 5,156,864 peak
lua-5.1-work4: 0.46 secs, 5,476,352 peak

> For 5000 iterations, it uses more memory but now it is 10% 
> faster than 5.02.

iters = 5000, listlen = 100

luarc: 1.12 secs, 2,981,888 peak
lua-5.0.2: 1.72 secs, 5,156,864 peak
lua-5.1-work4: 3.06 secs, 7,393,280 peak

> With list length 200, 5000 iterations,
> work4 uses 7963 memory, whereas 5.0.2 only uses 4694.
> [And work4 is again 10% faster]

iters = 5000, listlen = 200

luarc: 2.25 secs, 5,214,208 bytes
lua-5.0.2: 3.37 secs, 9,555,968 bytes
lua-5.1-work4: 9.19 secs, 14,245,888 bytes

> Finally I tried to keep 500 lists instead of 100.
> The two collectors performed about the same.

iters = 5000, listlen = 500

luarc: 5.92 secs, 11,931,648 bytes
lua-5.0.2: 10.64 secs, 22,790,144 bytes
lua-5.1-work4: 47.40 secs, 34,275,328 bytes

Just so I didn't screw this up (I hope)... this is what I used.  I didn't
call a collectgarbage() anywhere... just used the function provided.

iters = 5000
listlen = 500
master = {}

function mklist(n,tail)
  if n == 0 then return tail end;
  local head = {}
  local t = tail
  local m = n - 1
  t2 = mklist(m,t) -- deliberately not tail rec
  local node = {}
  node.link = t2
  node.data = n
  return node
end

-- First test only
--for i = 1,iters do master[1]=mklist(listlen,nil) end

for i = 1,iters do
  local j = i
  if j > 100 then j = 0 end
  master[j]=mklist(listlen,nil)
end

Josh