lua-users home
lua-l archive

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


I always knew that lpeg was decently quick, but I had a nice
experience this weekend that really drove the point home.

I use Lua as a frontend-language for my raytracer.  For testing
purposes, I thought it would be nice to write a parser for the input
language of another raytracer, "PBRT", so I could compare the results
of rendering exactly the same scene.

PBRT is written in C++, and uses a yacc/lex parser for its input
files.  I wrote my parser using LPeg and Lua, taking no special
measures for speed, and doing lots of error checking and other
post-processing in Lua.

As it turns out, however, my LPeg/Lua parser is not only decently
fast, but actually seems much _faster_ than PBRT's yacc/lex parser.
For some fairly large and complex input files (millions of lines), my
LPeg/Lua frontend can read them in less than half the time that PBRT
takes.  I got even more speedup later by linking with luajit.

Anyway, it's just an anecdote, and I suppose PBRT's parser might be
doing something really stupid that slows it down a lot, but I'm quite
impressed...

-miles

-- 
Cat is power.  Cat is peace.