LB Booster
« Effect of variable length on speed »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:37am



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: Effect of variable length on speed  (Read 145 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Effect of variable length on speed
« Thread started on: Nov 25th, 2017, 12:03pm »

There has been some discussion at the LB Yahoo! group on the effect of variable name length on execution time. Just for interest, these are the results I got from LB 4.5.1 and LBB 3.09 when running the program listed below:

LB 4.5.1:
Long variable name: 798
Short variable name: 793


LBB 3.09:
Long variable name: 115
Short variable name: 98


So the effect of variable name length is more significant in LBB, but even with the long name it runs 7 times faster.

Richard.

Code:
    t1 = time$("ms")
    for i = 1 to 1000000
    next
    t2 = time$("ms")
    for i = 1 to 1000000
      aVeryLongNumericVariableName = i
    next
    t3 = time$("ms")
    for i = 1 to 1000000
      a = i
    next
    t4 = time$("ms")

    print "Long variable name: "; (t3 - t2) - (t2 - t1)
    print "Short variable name: "; (t4 - t3) - (t2 - t1) 
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Effect of variable length on speed
« Reply #1 on: Nov 27th, 2017, 06:03am »

Interesting! I would not have thought the length of a variable name would make any difference at all.

Wont change my programming style though, I like to have names that are self descriptive smiley
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Effect of variable length on speed
« Reply #2 on: Nov 27th, 2017, 08:37am »

on Nov 27th, 2017, 06:03am, RobM wrote:
I would not have thought the length of a variable name would make any difference at all.

Typically it will make a difference in the case of a language that supports the EVAL function (like Liberty BASIC and BBC BASIC) because the original variable names must be retained in the running program in case they are referenced that way:

Code:
    input "Enter the name of a variable: ";var$
    print "That variable currently has the value ";EVAL(var$) 

BBC BASIC provides a 'compiler directive' that allows the programmer to specify which variable names need to be retained, and which don't (the default), which provides the best of both worlds. But - although in principle it could have done - LBB has not inherited this feature.

Richard.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Effect of variable length on speed
« Reply #3 on: Nov 27th, 2017, 9:33pm »

Thanks. I was wondering why it would make a difference and that pretty much explains it!
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