lua-users home
lua-l archive

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

Thanks for the feedback, I did understand that switching to a cross compiled binary would only effect my initial loading time not my execution speed. On the subject of the squishing down the original source code and using that, I have also experimented with that idea. From my experience I would highly recommend K H Mans  "Lua Src Diet", thats a very neat program and worked very well for me.
I finally got around to rewriting my Lua to C source code utility program so that it could work with either a Lua Binary or Lua ASCII script.
I got a better speed up that I was anticipating. Here are the numbers I measured on my slowish CPU/Flash Target board.
For a pretty big Lua program,
LUA Script as ASCII source  load time  = 2.4 Seconds 
LUA Script as X compiled Binary chunk  load time = 0.25 Seconds
Excellent !
> Date: Wed, 6 Jun 2012 13:49:06 -0700
> From:
> To:
> Subject: Re: Need a bit of help with a lua loading problem please
> On Tue, Jun 5, 2012 at 5:39 PM, Ashwin Hirschi <> wrote:
> >> The only reason to pre-compile chunks, really, is because you'vestripped
> >> the parser out of your lua vm. byte code is less portable,harder to deal
> >> with (as you've found), and not really faster to load
> You chopped the last part of my sentence:
> >> (and if you are loading code in a critical speed path, you probably shouldn't be)
> > I disagree. In my experience loading compiled chunks is (much) faster than
> > loading source code.
> If your run-time is A+B, making it A/4 + B sounds great... unless B >>> A.
> If you notice load time, lua is spending about as much time loading
> scripts as running them. I'm sure there are programs where thats just
> the way it is, or that have so much lua code loading at startup that
> startup is being slowed down, but its worth making sure this is your
> situation before optimizing load time.
> Btw, to the original poster, if size of the script is a problem,
> compression might be a good idea (at the price of code size, but maybe
> you have lots of ROM for zlib, or already have decompression code),
> but there are also various src diet programs around that will rewrite
> lua code into smaller lua code (shorten identifiers, strip white space
> and comments, etc.). Also, maybe this is obvious, but uncompiled lua
> src is compiled at load time, so after load, there is no difference in
> execution speed (in other words, its not the case that uncompiled code
> is run in some kind of slower interpreted mode).
> Cheers,
> Sam