lua-users home
lua-l archive

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


gary ng wrote:
--- Hans Hagen <pragma@wxs.nl> wrote:

Mariano Kamp wrote:

  Any ideas and hints what I can do to make things
faster and/or prettier?

- lpeg: much faster than string match
- no metatable: less code and less function calls
(not faster here)
- binary read: no need to parse line endings in io

- the lpeg can probably be made faster (no time to
look into it now)

I can confirm that lpeg is much faster than hand coded
string match.

btw, when making lpegs it helps a bit if one knows what to expect

0.297: parser = ((1-complete)^0 * complete * (1-newline)^0 * newline)^0 0.295: parser = (complete * (1-newline)^0 * newline + 1 )^0 0.312: parser = (complete + 1)^0

sometimes the last method is faster, but not here

However, my experience is that lua's sort() function
is noticeably slower than python's. I am not sure how
it compares with ruby or perl.

maybe the overhead of the function call

anyhow, in this case (large amount of data) the time spend on sort seems to be small

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------