LB Booster
« Line numbers are slower »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:15am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Line numbers are slower  (Read 555 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Line numbers are slower
« Thread started on: Aug 6th, 2015, 1:07pm »

Bad habits die hard and I must admit that I still use line numbers. embarassed

Some time ago Richard alluded to the possibility that a long program that used line numbers would probably run slower than one that simply used branch labels.

Well my program has over 1500 lines of code and each one has a line number. Awful I know. So I wrote a short program to strip out the line numbers and replace the branches with labels instead.

I am happy to confirm that my program now runs between 8-10% faster as a consequence.

Now not all programs are so long or time critical, but for those that are, here's another good reason to knock this bad habit on the head grin

User IP Logged

jorgerhv
New Member
Image


member is offline

Avatar




PM


Posts: 1
xx Re: Line numbers are slower
« Reply #1 on: Aug 7th, 2015, 1:01pm »

Would you share the code ?
Thanks
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Line numbers are slower
« Reply #2 on: Aug 7th, 2015, 3:37pm »

on Aug 7th, 2015, 1:01pm, jorgerhv wrote:
Would you share the code ?

Just to clarify, the presence of line numbers doesn't of itself result in a slowing of the program. It's only their use as the destination of a GOTO, GOSUB or RESTORE that is (relatively) slow.

So you can leave the line numbers, if you wish, but adding labels as the destination of branches can speed things up a little.

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Line numbers are slower
« Reply #3 on: Aug 7th, 2015, 6:57pm »

The code to strip out line numbers and replace them with labels? Sure. To use it you have to paste your code to a text file, save the altered version back to a text file and then copy it back into LB or LBB.

...but before I do, are there any instructions other than GOTO GOSUB THEN and ELSE that can be followed by a line number?
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Line numbers are slower
« Reply #4 on: Aug 7th, 2015, 7:25pm »

I used to use REMLINE.BAS (easily googled) to remove extra line numbers. That is, ones not used as destination.

(again, this will leave exactly only line numbers which slow down LBB wink )
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Line numbers are slower
« Reply #5 on: Aug 7th, 2015, 7:33pm »

Yes, I was sure someone must have written something similar smiley
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Line numbers are slower
« Reply #6 on: Aug 7th, 2015, 7:36pm »

on Aug 7th, 2015, 6:57pm, Monkfish wrote:
...but before I do, are there any instructions other than GOTO GOSUB THEN and ELSE that can be followed by a line number?

As I stated in my earlier reply, RESTORE is another. In fact it's the only use of a label which doesn't have a better alternative. GOSUB can be replaced by CALL, event handlers can use SUBs, and GOTO is avoidable altogether by using DO or WHILE. Oh, and ON ERROR GOTO can be replaced by TRY...CATCH!

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls