slow, then fast execution

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

slow, then fast execution

Post by dunbarx » Wed Jun 08, 2022 7:53 pm

I have a little handler that counts the number of actual working lines of a certain project along with the total number of lines. I have done this sort of thing since 1987.

The results are about 14,000 working lines and 21,000 total lines (these include comments, blank lines, etc). There are eight substacks and a mainstack, and all in, about 25 cards total.

The first time I run the process in a new session it takes perhaps 15 seconds. But any subsequent run takes only one second. How is that? All stacks are fully saved in each run. I assume everything that could have been compiled has already been. What is "buffered" after the first run?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: slow, then fast execution

Post by jacque » Thu Jun 09, 2022 6:15 pm

I'm guessing LC has to compile scripts on every new session. If the compiler saved its results to the stack, as it does in a standalone, you couldn't edit the scripts. They're saved as plain text for use in the IDE.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: slow, then fast execution

Post by dunbarx » Thu Jun 09, 2022 6:19 pm

Jacque.

Well, sounds right. :wink:

But what does "saves its results to the stack" really mean? The engine "reads" each script all over again, compiles it and then runs it?

OK, but compiling itself only takes a fraction of a second. I was not surprised at the long processing time, since there was considerable navigation required. But even if all scripts are pre-compiled, that navigation still has to be done.

So if the "navigation" however that is done, and I assume not by actually "going" anywhere, then that portion is a constant, and it must be the compiling itself that takes all that time.

Just doesn't seem proportionate.

Craig

Post Reply

Return to “Talking LiveCode”