Very slow stepping thro code (7000 lines)

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Mon Dec 23, 2019 7:49 pm

Hi folks

I know this has come up before (from me at least). I am using a stack only script as a behaviour stack. It's convenient as I can use GitHub to track changes. The script is now nearly 7000 lines and I have noticed that it has slowed down as the script has got longer. This is especially noticeable when stepping thro code (usually using "Step Over"). I am using a Mac (Catalina) and each step takes over a second, and all text operations are similar, e.g putting a carriage return. Are there any tricks I can use to shorten the delay?

I am working on transferring to Trevor's Levure. From what I understand we can step using Sublime Text and the the IDE responds. But in any case I would like to speed up native LiveCode for debugging.

Thanks.

Kaveh
Kaveh

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Very slow stepping thro code (7000 lines)

Post by bogs » Mon Dec 23, 2019 8:21 pm

This may sound canned or trite, but is meant as neither. Mind you, I also don't have Catalina, Lc 9.x, etc to test with.
kaveh1000 wrote:
Mon Dec 23, 2019 7:49 pm
The script is now nearly 7000 lines and I have noticed that it has slowed down as the script has got longer.
Go through the code, and make it more efficient. Lots of times, when writing code, you write some code that is overly long or more complex than it need be, but it works (or seems to), so you forget about it.

7k lines in a behavior seems a bit over-much (mind you, I am no expert in behavior scripts either, but I've written full db programs with fewer lines of code than that, so relatively speaking, it sounds a bit much).

Option 2 -
You've gone over the code, and don't think you can eliminate anything (which I find hard to believe) :P but if that is the case in fact, break that behavior into multiple script only stacks.

Option 3 -
If neither of the above work, move your computer outside and place an M80 under it, light the wick, watch the fun... Ok, that was both trite and canned, I'm sorry
Image

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Mon Dec 23, 2019 8:28 pm

Hi Bogs

You can say anything to me and not offence taken! You have helped a lot in the past.

The code was spread around the stack before, but I gradually moved all to one place so a crash would not be so serious. So I just keep track of code in one place.

I agree now that moving related code to several stacks would be better. And there is no doubt the code can be made more efficient. That is what I am trying to do now, but it is painful to do that too because of the slow speed!

I will definitely think of splitting the code now to have 3-4 stacks. In the meantime any more ideas welcome...

Thanks.

K
Kaveh

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by FourthWorld » Mon Dec 23, 2019 9:15 pm

7k lines is not a lot. Which version of LC? And is the problem evident in both debugging and editing?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Mon Dec 23, 2019 9:31 pm

It has been the same in several versions, from 9.4. I have just moved from 9.5.0 to 9.5.1 stable (all Indy).

Just measured stepping in debug mode from one line to next of simple code around 4-5 seconds which is painful.

It is slow to edit and to step. Enter carriage return takes around a second.

I just tried switching off autocomplete, etc (see screenshot) but no improvement.
Attachments
Screenshot 2019-12-23 at 20.27.00.png
Kaveh

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Very slow stepping thro code (7000 lines)

Post by bogs » Mon Dec 23, 2019 9:34 pm

FourthWorld wrote:
Mon Dec 23, 2019 9:15 pm
7k lines is not a lot. Which version of LC? And is the problem evident in both debugging and editing?
kaveh1000 wrote:
Mon Dec 23, 2019 7:49 pm
This is especially noticeable when stepping thro code (usually using "Step Over").
... each step takes over a second, and all text operations are similar, e.g putting a carriage return.
Richard would know far more than I, but to me, 7k lines still seems a lot.

I would uncheck all the things in options, especially live errors.
Image

pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm

Re: Very slow stepping thro code (7000 lines)

Post by pderks » Tue Dec 24, 2019 10:46 am

Hi Kaveh,

my central stack's script - used by nearly all my other stacks - contains 426 handlers & 279 functions and occupies 12022 lines & 441972 characters. I experience no execution or edition speed differences dependent on script length(s).

Peter

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Tue Dec 24, 2019 10:51 am

Thanks. I have no problem with execution. My problem is slow debugging, and editing. Takes 4-5 secs to go from one simple line to another, e.g.

put 5 into a
put 6 into b

and when typing I have to wait for the characters to catch up.
Kaveh

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Very slow stepping thro code (7000 lines)

Post by sphere » Tue Dec 24, 2019 12:05 pm

you guys/girls make me curious, what kind of programs is what you make which needs so many handlers and lines?

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Tue Dec 24, 2019 12:19 pm

The more functionality you need, the more lines. I am processing complex text. There is probably some duplication, but I would still have several 1000 lines.

I do have a habit of breaking lines to make them more readable, e.g.

Code: Select all

local var1, \
      var2, \
      ...
so yes, I could save a huge number of lines if I compact these. I just counted and only 750 such breaks, so would only save 10% of lines.
Kaveh

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Very slow stepping thro code (7000 lines)

Post by AxWald » Tue Dec 24, 2019 1:00 pm

Hi,
have you tried editing/ debugging with a version where you removed those "cosmetic line breaks"? Should be easy to test.

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Very slow stepping thro code (7000 lines)

Post by bogs » Tue Dec 24, 2019 1:07 pm

sphere wrote:
Tue Dec 24, 2019 12:05 pm
you guys/girls make me curious, what kind of programs is what you make which needs so many handlers and lines?
Heh, I'm with you. I guess I am just not 'big time' enough to think along lines that large :D
FourthWorld wrote:
Mon Dec 23, 2019 9:15 pm
7k lines is not a lot.
pderks wrote:
Tue Dec 24, 2019 10:46 am
my central stack's script - used by nearly all my other stacks - contains 426 handlers & 279 functions and occupies 12022 lines & 441972 characters.
I also may be suffering from a misconception of the problem as described, though. As described initially, I am thinking the 7k lines are in one behavior script that is not broken up into various functions and handlers, but used in a looping manner in a single handler, and does *not* include the lines of the rest of the program.

Peter, your description sounds more like an average way I see programs written, although that (to me) is still a huge amount of lines for anything short of a small operating system.
Image

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Very slow stepping thro code (7000 lines)

Post by kaveh1000 » Tue Dec 24, 2019 2:10 pm

I also may be suffering from a misconception of the problem as described, though. As described initially, I am thinking the 7k lines are in one behavior script that is not broken up into various functions and handlers, but used in a looping manner in a single handler, and does *not* include the lines of the rest of the program.
Perhaps I described incorrectly. The 7000 lines are the stack script of a script only stack. My main stack has its behaviour set to this stack.

Actually my slow debugging problem is not related to the behaviour stack. You could think of having a stack with a huge stack script, and I would have the same problem.

There are lots of handlers (140) and functions (230). I have very few long handlers and functions. I try to split them up.

I don't see anything unusual in having this many lines and I am not a high level programmer. It's just separate functionalities that I have added as I need them.
Kaveh

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Very slow stepping thro code (7000 lines)

Post by bogs » Tue Dec 24, 2019 2:22 pm

Ok, my initial impression was way off then. I have nothing else to offer :(
Image

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Very slow stepping thro code (7000 lines)

Post by sphere » Tue Dec 24, 2019 2:38 pm

Thanks for some insight, i'm going to count a few (for me challenging) stacks of myself to see how many lines it actually has and the amount of handlers.
Still comparing is of course not easy as one does not know exactly what the stack of someone else tries to accomplish.

I

Post Reply