LB Booster
« LBB runs 7 times slower than LB on my GBRL-Sender »

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



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 2 3 4  5 Notify Send Topic Print
 locked  Author  Topic: LBB runs 7 times slower than LB on my GBRL-Sender  (Read 1582 times)
xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 27
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #8 on: Dec 21st, 2017, 9:41pm »

After removing 90% of my button, etc.
LBBrun is 28 sec LBB exe is 100 seconds LB is 28 seconds

hmmmm LBB has problem with how many buttons etc????
I have approx
130 buttons
12 graphic boxes
2 text editor
7 list boxes
6 text boxes
4 combo boxes
15 statictext
Code:
[InitColors]
    'Please use default colors when possible.
    'ForegroundColor$ = "Black"
    'BackgroundColor$ = "Buttonface"
    True = 1 : False = 0
'------------ 
[WindowSetup]
 NOMAINWIN                                               '    allow no print window
    WindowWidth = 1020 : WindowHeight = 700   '877
    UpperLeftX = INT((DisplayWidth-WindowWidth)/2)        '    UpperLeftX = DisplayWidth-WindowWidth
    UpperLeftY = INT((DisplayHeight-WindowHeight)/2)      '    UpperLeftY = DisplayHeight-WindowHeight
    Menu #main, "DROreset", "Reset MPX", [ZX], "Reset MPY", [MZY], "Reset MPZ", [MZZ], "ResetALL", [MZR]
    Menu #main, "HELP", "Q/A.txt", [HELPx],"LibertyBasic.chm",[HELPchm],"LB-Forum",[HELPforum]
bucketdelay=3
'-------------- 
[ControlSetup]
'-------------- 
statictext  #main.statictext2, "MPOS", 60, 105, 40, 20
statictext  #main.statictext3, "WCO", 230, 105, 25, 20
statictext  #main.statictext4, "WPOS", 350, 105, 40, 20 
textbox     #main.ManualTx, 5, 475, 470, 20                                   ' over-down-width-height
stylebits   #main.Enter, _BS_DEFPUSHBUTTON,0,0,0                              ' Enable ENTER Key
button      #main.Enter,"",[Enter],UL,473,475,5,20                            ' hidden button sort of !
button      #main.ManualSend, "SEND COMMANDS", [SEND], UL, 190, 500, 180, 20 
'=========== 
texteditor  #main.WinStatus, 55,125, 420, 80         ' LBB adjust   ' Top left Corner - over, down
texteditor  #main.GCwindow, 55, 210, 420, 260        ' LBB adjust   ' bottom right - width, down
stylebits   #main.Mag1, _ES_CENTER,0,0,0                                      '
textbox     #main.Mag1, 435, 575, 40, 20                                      '
button      #main.rtz, "RTNZERO", [Ret2ZERO], UL, 375, 600, 60, 30            '
button      #main.magnify, "MAG",[MAGNIFY],UL,435,600,40,30                   '**************
stylebits   #main.PLOTa, _ES_CENTER,0,0,0                                     '
textbox     #main.PLOTa, 435, 525, 40, 20                                     '
button      #main.plotting, "PLOT",[PLOTXY],UL,435,550,40,20                  '                                                                             '
graphicbox  #main.Status, 188, 522, 180, 50                                   ' **************
'--------- 
button      #main.MZX, "Zx", [MZX], UL, 165, 0, 30, 30            '
button      #main.MZY, "Zy", [MZY], UL, 165, 35, 30, 30           '
button      #main.MZZ, "Zz", [MZZ], UL, 165, 70, 30, 30           '
button      #main.MZR, "ZR", [MZR], UL, 195, 0, 25, 100           '                                                                 
stylebits   #main.DROMPx, _ES_RIGHT,0,0,0                         '
textbox     #main.DROMPx, 55, 0, 110, 30                          ' Right Justify & TextboxColor$ = "White"
stylebits   #main.DROMPy, _ES_RIGHT,0,0,0                         '
textbox     #main.DROMPy, 55, 35, 110, 30                         '
stylebits   #main.DROMPz, _ES_RIGHT,0,0,0                         '
textbox     #main.DROMPz, 55, 70, 110, 30                         '                                                                  
stylebits   #main.DROWCx, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWCx, 220, 0, 110, 30                         '
stylebits   #main.DROWCy, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWCy, 220, 35, 110, 30                        '
stylebits   #main.DROWCz, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWCz, 220, 70, 110, 30                        '                                                                  
stylebits   #main.DROWPx, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWPx, 330, 0, 110, 30  '480                   '
stylebits   #main.DROWPy, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWPy, 330, 35, 110, 30                        '
stylebits   #main.DROWPz, _ES_RIGHT,0,0,0                         '
textbox     #main.DROWPz, 330, 70, 110, 30                        '
'------------ 
listbox     #main.S1, SA$(),[Prm1],476,125,102,108                '
listbox     #main.S2, SB$(),[Prm2],580,125,102,108                '
listbox     #main.S3, SC$(),[Prm3],686,125,102,108                '
listbox     #main.S4, SD$(),[Prm4],792,125,102,108                '
listbox     #main.S5, SE$(),[Prm5],898,125,102,108                '
texteditor  #main.PopUp, 500, 250, 475,350                        '
graphicbox  #main.Plot3, 476, 235, 525,405                        ' home is 0,405
 
'   START UP VALUES 
    Thirty=time$("seconds")                                       ' seconds since midnight                                                                 '
  Open "Liberty Basic GRBL GUI" for Window as #main               '
    #main "trapclose [quit]"                                      '
'------------ 
  #main.GCwindow, "TotalScreen Width = "; DisplayWidth            '
  #main.GCwindow, "TotalScreen Height = ";  DisplayHeight         '
  x$=time$()                           ' setup 1st time msg
  TmvalNu=val(mid$(x$,4,2))*60         ' setup 1st time msg
  TsvalNu=val(right$(x$,2))+TmvalNu    ' setup 1st time msg
'============= 
[LoadMacros]   '' code removed                                                    '
[Glog]         '' code removed                                                    '
[ErrLoop1]     '' code removed                                                    '
[LoopExit]     '' code removed                                                    ' wait for user input
    timer bucketdelay, [ckbuf]                                    ' every 3 ms ckbuf
    wait                                                          '
'--------------------------------------------------------------------------------------------------------
[ckbuf]                                                          '
    Qcnt=Qcnt+1                                                  '
 ''   print Qcnt;"-";    '' added speeds up when move window
  #main.WinStatus, Qcnt  '' trying this
'--------------------------------------------------------------------------------------------------------
  if Qcnt >1775 then                                             ' approx 30+ sec elapsed
      x$=time$()                                                 '
      TsvalOld=TsvalNu                                           ' last total seconds -> old
      TmvalOld=TmvalNu                                           ' last m*60  seconds -> old
      TmvalNu=val(mid$(x$,4,2))*60                               ' get nu m *60 seconds 9*60=540 0*60=0 ==600
      TsvalNu=val(right$(x$,2))+TmvalNu                          ' compute new total seconds
      xx = abs(TsvalNu-TsvalOld)                                 ' compute new-old
      #main.GCwindow, "<";Qcnt;">  <";xx;"> ";x$                 ' 1st display & every hour = funny number
      Qcnt=0                                                     '
  end if                                                         '
  if CommOpen=0 then [LoopExit]                                  ' can't get input if comm closed
'------------[getbuffer]      '' code removed                                '
[getmessage]       '' code removed                                              '
[loopx]             '' code removed                                             '
[PreProcess]                                                    '
 '' timer 0                                                       ' stop timer until line processed *****
 '' code removed
[StepWait]
 '' code removed
[PrintResponse]                                                 ' 3 ms 28a
       '' code removed
      goto [LoopExit]                                           ' **************************
[ESTOP]
[quit]                                                          '
      '' code removed
     close #main                                                ' main window
END                                                             ' must stop main


 
« Last Edit: Dec 21st, 2017, 9:49pm by xtal » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #9 on: Dec 21st, 2017, 10:44pm »

on Dec 21st, 2017, 9:41pm, xtal wrote:
This runs slow until I move the print window, then it speeds up ?

This is almost certainly a sign of CPU throttling. If you are using a laptop it is not uncommon. Go into Windows' performance settings and force the CPU to run at full speed: it will drain the battery, but at least anomalies such as this shouldn't happen.

Quote:
After removing 90% of my button, etc.
LBBrun is 28 sec LBB exe is 100 seconds LB is 28 seconds

There are three ways of running a program using LBB: one is to run it from the LBB IDE, the second is to 'compile' it to an EXE and run that, the third way is to export a tokenised program and run that using LBBRUN.exe.

Because of the way LBB works, there will never be a significant difference between the execution speed of these three methods. The 'compiled' EXE may be slightly faster than the other two, but only a few percent at most.

I think I said this before, but if you want to find out why LBB is slower than LB, then use the profiler (Run... Profile Program menu selection or Ctrl+F5). This will show you exactly where the time is being spent.

I could make LBB significantly faster than it is, by replacing the LBLIB library (coded in BBC BASIC - one of the slowest BASICs) with a DLL coded in C. But I'm not going to do that, partly because it would be a lot of work and partly because LBB is intended to be a showcase for BBC BASIC.

Richard.
« Last Edit: Dec 22nd, 2017, 12:12am by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #10 on: Dec 22nd, 2017, 12:11am »

on Dec 21st, 2017, 9:41pm, xtal wrote:
Code:
    bucketdelay=3
    timer bucketdelay, [ckbuf]  ' every 3 ms ckbuf
    wait 

Don't forget that, in both LB 4 and LBB, the shortest timer period is about 10 ms. Attempting to set it to 3 ms, as in your code, won't result in an error but it won't make it any faster.

Richard.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 27
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #11 on: Dec 22nd, 2017, 11:11am »

Thx for the 3 ms info, I knew there was a limit somewhere , just didn't know what it was rolleyes

As for CPU Throttle ? I'm running a QuadCore Desktop with 8GB memory, So I don't suspect any throttling and will attempt to check it out, but if that is the problem then why moving the print window would make it speed up huh

And why the speed increase after removing many button's etc,, the screen display only has 2 texteditor windows in play in this example embarassed
« Last Edit: Dec 22nd, 2017, 11:18am by xtal » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #12 on: Dec 22nd, 2017, 12:58pm »

xtal,
I've run your code from Reply #8
(EDIT: on Win XP upon Intel Core I5)
LBB
28 sec
produced EXE
28 sec
produced LBB, run with LBBRUN.exe
28 sec

BTW
1776*0.016 is 28.416

So if you have more that should mean some stuff between WAIT took more then 16 ms (not say 3 ms your planned)
(so it fired on next 16'th. Or some next after that)

You probably should try profiler to see that takes time.
« Last Edit: Dec 22nd, 2017, 12:59pm by tsh73 » User IP Logged

Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #13 on: Dec 22nd, 2017, 1:32pm »

Anything to do with the Windows timer takes time. Free running your code was looping in 0-1 second on my machine. introducing any form of time$( timer function drags the system down. As Richard says it adds 10 or more milliseconds of wasted time per loop. If you need it to run that fast consider other code as a time waster, or worst case a while wend loop that balances the time delay you need.

But why are you needing the delay? if the display is live and reading stuff real time what is the point of the delay?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #14 on: Dec 22nd, 2017, 4:14pm »

on Dec 22nd, 2017, 11:11am, xtal wrote:
but if that is the problem then why moving the print window would make it speed up huh

Windows gives processes that the user is interacting with a higher priority, so it's possible that moving a window may increase the CPU clock rate of the core that your program is running on. You can try using a tool like CPU-Z to monitor the clock speeds.

Quote:
And why the speed increase after removing many button's etc

Most likely a coincidence. One plausible way in which the presence of many buttons could affect execution speed is if the additional memory usage causes cache thrashing. But I would expect the effect to be small.

In your program most of the time (around 90% here) is spent in the WAIT statement, as you would expect, so the execution time is pretty much determined by that.

Don't speculate, run the profiler!

Richard.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 27
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #15 on: Dec 22nd, 2017, 5:49pm »

I modified the test pgm, added back the print window, and I only have to click on the window for the program to speed up?

I was trying to verify the 10Ms , and
LB setting Bucketdelay using run program on LB and LBB
10-15 I get 15 ms delay
16 I get 25 ms delay
17-? I get 31 ms

LBB 10-12 I get 15 ms delay [must click print window 2 speedup on LBB but not on LB]]
13 - ? time starts increasing

I didn't expect to see these #'s
Could be Win10 Pro issue with unexpected delays?

Tried profiler , but I can't determine squat from it other than a big count at the wait .....

I think I lucked out getting My GCode sender working .
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #16 on: Dec 22nd, 2017, 10:12pm »

on Dec 22nd, 2017, 5:49pm, xtal wrote:
I only have to click on the window for the program to speed up?

Clicking on a window activates it, and brings the process to the foreground. So this suggests that non-foreground processes are running much more slowly than they should. Have you checked with Task Manager or Resource Monitor to see what processes are using CPU time? Is it possible that you have some 'zombie' LB or LBB programs still running (invisibly), for example because of not including a trapclose?

Quote:
Tried profiler , but I can't determine squat from it other than a big count at the wait .....

If the profiler is not recording the delays, multimedia interrupts (timeSetEvent) are not running properly, and if multimedia interrupts - which have a high priority - are not running, something is seriously broken!

Richard.
« Last Edit: Dec 22nd, 2017, 10:14pm by Richard Russell » User IP Logged

Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #17 on: Dec 23rd, 2017, 10:22am »

These delays are exactly what you should expect from the Windows timer. I always describe the timer as a clock face that only changes every 16ms or so.

Now this is a problem for the timer command because it has to look at the clock face and react when the desired time is shown. It seems we cannot see the time change faster than 16ms so it is pointless coding timer delays below this value.

Also because we start mid cycle it is variable, lengthening the delay does not help as you have seen because you tend to go up in 16ms increments and so jump from 16ms to 32ms.

So at the timings you are trying to get the timer is useless to you. Drop it and try SLEEP or simply loop.

That way you will lose your massive WAIT dely.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 27
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #18 on: Dec 23rd, 2017, 1:20pm »

If your thinking the 28 sec is a massive wait, it is not, it's just an indicator that the program is running without any unexpected delays, The bucketdelay wait is being used to process any serial data. Sometimes I have to stop the timer when going GCode processing / file reading etc, because invalidtag tag [ckbuf] is intermittantly displayed, then restart timer when leaving the code. Other than that the GCode pgm runs fine under LB.
User IP Logged

Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #19 on: Dec 23rd, 2017, 2:00pm »

smiley No, I was thinking 16ms is a massive delay if you have a lot to do.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #20 on: Dec 23rd, 2017, 5:30pm »

on Dec 23rd, 2017, 2:00pm, Rod wrote:
smiley No, I was thinking 16ms is a massive delay if you have a lot to do.

As far as I can see the OP is using the timer appropriately. As I understand it he is using it to process incoming serial data, so the important thing is that the serial input buffer cannot overflow between one timer 'tick' and the next. 16ms is not a "massive" amount of time from this perspective: even at 115,200 baud the maximum amount of data that can be received in 16ms is fewer than 200 bytes, which is much smaller than the size of the input buffer.

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #21 on: Dec 23rd, 2017, 9:21pm »

on Dec 23rd, 2017, 1:20pm, xtal wrote:
invalidtag tag [ckbuf] is intermittantly displayed

LB 4 has a bug which means that you cannot (safely) use the timer with a SUB handler but only with a branch label. This means that, as you found, it is possible for a timer event to fire when the target label is out-of-scope (e.g. when your program's execution is inside a sub or function), causing an error to be reported.

You can work around this by ensuring that your program never executes a SCAN or WAIT statement when inside a function or sub, that way the timer handler will only be called when its target is in scope. But that's a serious limitation; for example it prevents you encapsulating a GUI window and all its control handlers inside a SUB, which is often desirable from a structured programming viewpoint.

Fortunately LBB does not have that bug. You can safely use a SUB handler for your timer events, and since SUBs are always in scope you can use SCAN or WAIT statements anywhere you like within your program without any risk of an error. Of course you will probably want to make all your other event handlers SUBs as well, but that's good practice anyway (and works in LB).

Richard.
« Last Edit: Dec 23rd, 2017, 9:23pm by Richard Russell » User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 27
xx Re: LBB runs 7 times slower than LB on my GBRL-Sen
« Reply #22 on: Dec 24th, 2017, 3:18pm »

modified my complete program Many buttons etc...

LB = RUN LBB = RUN Program
''display TIC value - stop timer - set timer
[LoopExit] ' Display tic amount = 15 that I'm setting
#main.GCwindow, "Set TIC=";bucketdelay
timer 0
timer bucketdelay, [ckbuf] ' every 15 ms ckbuf
wait
' Set cnt to 99 instead of 1775
if Qcnt >99 then
'' COMPUTE TIC Time in millisec
mstime=int((etime/100)*10000)/10

LB = Run
Opened Dec 24, 2017 - 10:15:27
<10:15:28> <100> <1.659sec> <16.5msTIC>
<10:15:30> <100> <1.732sec> <17.3msTIC>
<10:15:32> <100> <1.697sec> <16.9msTIC>
<10:15:34> <100> <1.627sec> <16.2msTIC>
Closed Dec 24, 2017 - 10:15:34

Task mgr chrome 0.1-.3% lbpro 1-6%
notepad 0.1% taskmgr .3-1.1%


LBB = Run Program
Opened Dec 24, 2017 - 10:30:22
<10:34:52> <100> <314.259sec> <3142.5msTIC>
<10:40:03> <100> <311.731sec> <3117.3msTIC>
<10:45:16> <100> <312.729sec> <3127.2msTIC>
<10:50:27> <100> <310.503sec> <3105msTIC>
<10:55:37> <100> <310.218sec> <3102.1msTIC>
<11:00:49> <100> <311.957sec> <3119.5msTIC>
Closed Dec 24, 2017 - 11:05:06
--wow 3 second TIC time SB 15+ ms
Task mgr chrome 0.1-.3% LB Booster .1-1.3%
notepad 0.1% taskmgr .3-1.1%



Earlier I saw BBCwrun6 in task mgr apps @ 30% I have no Idea what that was , but now its gone ...
Again this is W10 pro
Tried compatility run whit same results
« Last Edit: Dec 24th, 2017, 3:22pm by xtal » User IP Logged

Pages: 1 2 3 4  5 Notify Send Topic Print
« Previous Topic | Next Topic »

| |

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