lua-users home
lua-l archive

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


On Wednesday 12 January 2011 04:42:18 steve donovan wrote:
> On Wed, Jan 12, 2011 at 11:37 AM, Steve Litt <slitt@troubleshooters.com> 
wrote:
> > So I guess I abused closures, huh?  :-)
> 
> It's a fine use of them, and I think the efficiency consideration only
> applies when there's lots of objects

Now I'm really laughing. My EMDL file is 4026 lines long, and I'd venture to 
say 4000 of them are non-blank, non-comment, and every non-blank, non-comment 
line gets its own EMDLItem object, and parent and child linkages put them all 
in a massive tree, and then I also have a stack and a menu array :-~

All's well that ends well. The Lua version seems to run about 40% faster than 
the Perl version, although both run in well under 1 seconds so it's hard to be 
sure. Below are a couple random running times...

===============================================================
slitt@mydesk:/d/at/perl/emdl$ time ./emdlinit.sh ./emdlcompile.sh 
/d/bats/s.emdlSeeking config file /d/at/perl/emdl/emdl.cfg.
There are no errors.


There are no warnings.

real    0m0.654s
user    0m0.528s
sys     0m0.024s
slitt@mydesk:/d/at/perl/emdl$
===============================================================
===============================================================
slitt@mydesk:/d/at/lua/emdl$ time ./emdl.lua /d/bats/s.emdl
/d/bats/s.emdl

There are no errors.
There are no warnings.


real    0m0.220s
user    0m0.184s
sys     0m0.028s
slitt@mydesk:/d/at/lua/emdl$
===============================================================

Of course, the algorithm I used in the Perl version kept walking a tree over 
and over again. It would be interesting to see what the algorithm I used in 
Lua would do in Perl. But ever since I started using Lua, I don't like Perl 
anymore :-;


> (as the greats of computing say,
> measure first, optimize next).
> 
> But it's wise to tell users about this dot business ;) [1]

Heckyeah! Consider it done.

> 
> steve d.
> [1] can of course use colon with objects-with-closure, if you give
> them a (dummy) first argument.

Naaa, I think one piece of sneakery is enough.

By the way, I really do like the closure way of doing methods, and would like 
to thank Lucas Zawacki for showing me how to do it in the "OOP Sortof" thread.

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt