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)
  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

to create a list repeatedly:

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

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

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.

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

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

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

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net