LB Booster
« Long strings »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:57am



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: Long strings  (Read 531 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Long strings
« Reply #1 on: Mar 26th, 2016, 7:57pm »

on Mar 26th, 2016, 6:31pm, HugoS wrote:
I have found LBB to be many, many times faster than LB in all respects except when looping through long strings with the word$() function.

Sorry, word$() is slow. The explanation is that there is no direct equivalent in BBC BASIC, so it has to be emulated at run-time - in interpreted BBC BASIC code!

If you've read the How It Works section of the LBB Help file you'll know that LBB is a hybrid translator and emulator. Statements and functions that have a direct equivalent in BBC BASIC are translated at 'compile time' and typically run up to ten times more quickly (possibly even faster). However features that don't have a direct equivalent in BBC BASIC are emulated at run time and typically run at about the same speed as, and sometimes slower than, LB 4.

Could you not do it this way, which is a lot faster than using word$(), and indeed a lot faster than your code running in LB 4.04:

Code:
    test$ = httpget$("http://www.dailymail.co.uk/home/index.html")
    aPos = instr(test$, "<body")
    bPos = instr(test$, "</body>")
    aFile$ = mid$(test$, aPos, bPos - aPos)

    aFile$ = lower$(aFile$)
    toFind$ = "james"
    aCnt = 0
    i = 0
    do
      i = instr(aFile$, toFind$, i+1)
      if i then 
        if trim$(mid$(aFile$, i-1, len(toFind$)+2)) = toFind$ then
          aCnt += 1
        end if
      end if
    loop until i = 0
    notice aCnt
    end
    
'include lb45func.bas
 

The actual counting process (i.e. excluding loading the file from the web) took 0.04 seconds here!!

Richard.
« Last Edit: Mar 26th, 2016, 11:24pm by Richard Russell » User IP Logged

HugoS
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Long strings
« Reply #2 on: Mar 26th, 2016, 9:09pm »

on Mar 26th, 2016, 7:57pm, Richard Russell wrote:
The actual counting process (i.e. excluding loading the file from the web) took 0.04 seconds here!!

Literally a blink of an eye! Much better, thank you Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Long strings
« Reply #3 on: Mar 27th, 2016, 12:19am »

on Mar 26th, 2016, 9:09pm, HugoS wrote:
Literally a blink of an eye! Much better, thank you Richard.

I should perhaps add that if there is no reasonable alternative to word$(), specifying the delimiter - if you are able to - will make it considerably quicker than the default case (when it is having to treat any 'whitespace' as the delimiter).

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