LB Booster
« Card graphics not sticking »

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



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 ... 1 2 3 4  Notify Send Topic Print
 veryhotthread  Author  Topic: Card graphics not sticking  (Read 198 times)
Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #33 on: May 23rd, 2016, 12:14pm »

Russell: Perhaps you misunderstood what I meant. The slower execution I was experiencing in LBB was entirely due to sloppy programming in my LB code to start with! I wasn't saying that LBB is or isn't inherently faster or slower, merely that my inefficient program was causing speed related problems, and that once fixed, ran well in LBB! I was actually praising LBB for identifying errors that were going unnoticed in LB.

I'm currently trying to modify part of my program that's showing a very noticeable difference in speed; but as before, it's likely some goof that I haven't caught yet. I've used the Profiler, but haven't identified anything worthy of passing along … yet. This may take a few days, but I'm trying to get to the bottom of things and will be glad to pass along the results as I find them.

I appreciate your continued help.
User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #34 on: May 23rd, 2016, 3:15pm »

Here's an example of a code snippet that runs noticeably slower in LBB than LB. It's not lifted from my program, which would only confuse, but is totally representative of what I'm trying to show.

The program populates a grid of 10 x 20 colored boxes as defined in the [Fieldvalues]. A left click on any box will sequence through 1-5 numbers and associated colors.

Here's the "problem": In LB, the program opens almost immediately, while it takes considerably longer in LBB. (The grid in my actual program is almost twice as large, and the time to load is even longer.) The opening (and closing) is by a button in another part of the program, and it's somewhat disturbing to watch the graph slowly fill in when using LBB as opposed to LB. (The sytlebits comment at the top of the program has been commented out. While the display could be hidden until finished loading, the delay is still not desirable.)

I hope I've committed some horrendous programming error and that there's a way of speeding things up. In any case, there's a noticeable difference in the time it takes to load in LB vs. LBB.

Any suggestions would be must appreciated. Thanks!


SORRY - I GOT A MESSAGE THAT THE CODE WAS TOO LONG. IT'S ONLY 300 LINES - HOW DO I ATTACH IT?
« Last Edit: May 23rd, 2016, 3:20pm by Turtleman » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #35 on: May 23rd, 2016, 3:40pm »

on May 23rd, 2016, 12:14pm, Turtleman wrote:
The slower execution I was experiencing in LBB was entirely due to sloppy programming in my LB code to start with!

Generally, "sloppy programming" won't cause things to run more slowly in LBB. If the program runs, which means your programming (whether it be 'sloppy' or otherwise) is compatible with LBB, it should benefit from a speed improvement, or at least not run significantly slower.

So very slow-running code in LBB is a concern, irrespective of the quality of your programming, because it's not expected. Because it's so easy to run the Profiler to find out where that slowness is arising, I ask you once again to do that and to post the relevant section(s) of the report file. Many thanks.

Richard.
User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #36 on: May 23rd, 2016, 3:48pm »

Got to run right now and may not be able to get back to this until tomorrow. I ran the Profiler and am trying to figure out how to post it along with my code. I'm very anxious to get to the bottom of this. Later!
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #37 on: May 23rd, 2016, 4:10pm »

on May 23rd, 2016, 3:48pm, Turtleman wrote:
I hope I've committed some horrendous programming error and that there's a way of speeding things up.

No. You have hit a rare 'edge case', which I have encountered only once before, in a program written by an Australian user. LBB is not suitable for your program - use LB instead.

Richard.
User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #38 on: May 23rd, 2016, 7:53pm »

Code:
 
Yikes – you're giving up without having even seen the code and running it! Let's not throw in the towel so quickly! If nothing else, it would be good to know what's going on. Code:
    'Graphic boxes demo - May 23, 2016
  
    nomainwin
    'stylebits #main, 0, _WS_VISIBLE, 0, 0     
    
    GridWidth = 40
    GridHeight = 25
    GridRows = 20
    GridColumns = 10
    MaxColors = 5

    dim counters(GridColumns, GridRows), colors$(MaxColors-1)

    restore [FieldValues]

    for row = 1 to GridRows
        for column = 1 to GridColumns
            read n
            counters(column, row) = n
        next
    next

    restore [FieldColors]

    for i = 0 to MaxColors-1
        read color$
        colors$(i) = color$
    next

    BoxWidth = GridColumns * GridWidth
    BoxHeight = GridRows * GridHeight
    WindowWidth = BoxWidth + 100
    WindowHeight = BoxHeight + 100

    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    graphicbox #main.gb22,                  50, 10,(GridWidth), 25
    graphicbox #main.gb23, (1 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb24, (2 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb25, (3 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb26, (4 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb27, (5 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb28, (6 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb29, (7 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb30, (8 * GridWidth +50), 10,(GridWidth), 25
    graphicbox #main.gb31, (9 * GridWidth +50), 10,(GridWidth), 25
   
    y = 15
    graphicbox #main.gb11, 5, 1 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb12, 5, 2 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb13, 5, 3 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb14, 5, 4 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb15, 5, 5 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb16, 5, 6 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb17, 5, 7 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb18, 5, 8 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb19, 5, 9 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb110, 5, 10 * GridHeight + y, GridWidth,GridHeight
   
    graphicbox #main.gb111, 5, 11 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb112, 5, 12 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb113, 5, 13 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb114, 5, 14 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb115, 5, 15 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb116, 5, 16 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb117, 5, 17 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb118, 5, 18 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb119, 5, 19 * GridHeight + y, GridWidth, GridHeight
    graphicbox #main.gb120, 5, 20 * GridHeight + y, GridWidth,GridHeight  
   
   
    graphicbox #main.gb, 50, 40, BoxWidth, BoxHeight
    open "Grid" for window as #main
    #main, "trapclose [quit.main]"
    #main.gb "down; font arial 10; size 1; color black"
    #main.gb "when leftButtonUp [IncreaseCounter]"
    #main.gb "when leftButtonDouble [IncreaseCounter]"
    gosub [InitGrid]
    
    gosub [title]  
    #main "show"
    wait

[quit.main]
    Close #main
    END

[IncreaseCounter]
    row    = int( MouseY / GridHeight) + 1
    column = int( MouseX / GridWidth) + 1
    counters(column, row) = counters(column, row) + 1
    if counters(column, row) > (MaxColors - 1) then counters(column, row) = 0
    #main.gb "delsegment GridUpdate"
    gosub [DrawField]
    #main.gb "flush GridUpdate"
    wait

[InitGrid]
    for row = 1 to GridRows
        for column = 1 to GridColumns
            gosub [DrawField]
        next
    next

    #main.gb "flush InitGrid"
    return

[DrawField]
    #main.gb "backcolor "; colors$(counters(column, row))
    #main.gb "place "; (column-1)*GridWidth; " "; (row-1)*GridHeight
    #main.gb "boxfilled "; column*GridWidth; " "; row*GridHeight
    #main.gb "place "; (column-.6)*GridWidth; " "; (row-.4)*GridHeight

    if instr(lower$(colors$(counters(column, row))), "dark") > 0 then #main.gb "color white"
    #main.gb "\"; counters(column, row)
    if instr(lower$(colors$(counters(column, row))), "dark") > 0 then #main.gb "color black"
    return

[FieldValues]
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4
    data 0, 1, 2, 3, 4, 0, 1, 2, 3, 4

[FieldColors]
    data "red"      '0
    data "green"    '1
    data "cyan"     '2
    data "yellow"   '3
    data "pink"     '4
  
[title]
'REM  1
    #main.gb22, "down; fill yellow; color black; backcolor yellow"
    #main.gb22, "place 10 17; font arial 12 bold"
    #main.gb22, "\1"
    #main.gb22, "flush"
'REM  2
    #main.gb23, "down; fill yellow; color black; backcolor yellow"
    #main.gb23, "place 10 17; font arial 12 bold"
    #main.gb23, "\2"
    #main.gb23, "flush"
'REM  3
    #main.gb24, "down; fill yellow; color black; backcolor yellow"
    #main.gb24, "place 10 17; font arial 12 bold"
    #main.gb24, "\3"
    #main.gb24, "flush"
'REM  4
    #main.gb25, "down; fill yellow; color black; backcolor yellow"
    #main.gb25, "place 10 17; font arial 12 bold"
    #main.gb25, "\4"
    #main.gb25, "flush"
'REM  5
    #main.gb26, "down; fill yellow; color black; backcolor yellow"
    #main.gb26, "place 10 17; font arial 12 bold"
    #main.gb26, "\5"
    #main.gb26, "flush"
'REM  6
    #main.gb27, "down; fill yellow; color black; backcolor yellow"
    #main.gb27, "place 10 17; font arial 12 bold"
    #main.gb27, "\6"
    #main.gb27, "flush"
'REM  7
    #main.gb28, "down; fill yellow; color black; backcolor yellow"
    #main.gb28, "place 10 17; font arial 12 bold"
    #main.gb28, "\7"
    #main.gb28, "flush"
'REM  8
    #main.gb29, "down; fill yellow;color black; backcolor yellow"
    #main.gb29, "place 10 17; font arial 12 bold"
    #main.gb29, "\8"
    #main.gb29, "flush"
'REM  9
    #main.gb30, "down; fill yellow; color black; backcolor yellow"
    #main.gb30, "place 10 17; font arial 12 bold"
    #main.gb30, "\9"
    #main.gb30, "flush"
'REM  10
    #main.gb31, "down; fill yellow; color black; backcolor yellow"   'REM      255, 153, 0"
    #main.gb31, "place 5 17; font arial 12 bold"
    #main.gb31, "\10"
    #main.gb31, "flush"


'REM  VERTICAL COLUMN LABELS ----------------------------------------------------------------------
'REM  1
    #main.gb11, "down; fill white; color black; backcolor white"
    #main.gb11, "place 14 20; font arial 12 bold"
    #main.gb11, "\1"
    #main.gb11, "flush"

'REM  2  #main.gb91, "down; fill white; color black; backcolor white"
    #main.gb12, "place 14 20; font arial 12 bold"
    #main.gb12, "\2"
    #main.gb12, "flush"
'REM  3
    #main.gb13, "down; fill white; color black; backcolor white"
    #main.gb13, "place 14 20; font arial 12 bold"
    #main.gb13, "\3"
    #main.gb13, "flush"
'REM  4
    #main.gb14, "down; fill white; color black; backcolor white"
    #main.gb14, "place 14 20; font arial 12 bold"
    #main.gb14, "\4"
    #main.gb14, "flush"
'REM  5
    #main.gb15, "down; fill white; color black; backcolor white"
    #main.gb15, "place 14 20; font arial 12 bold"
    #main.gb15, "\5"
    #main.gb15, "flush"
'REM  6
    #main.gb16, "down; fill white; color black; backcolor white"
    #main.gb16, "place 14 20; font arial 12 bold"
    #main.gb16, "\6"
    #main.gb16, "flush"
'REM  7
    #main.gb17, "down; fill white; color black; backcolor white"
    #main.gb17, "place 14 20; font arial 12 bold"
    #main.gb17, "\7"
    #main.gb17, "flush"
'REM  8
    #main.gb18, "down; fill white; color black; backcolor white"
    #main.gb18, "place 14 20; font arial 12 bold"
    #main.gb18, "\8"
    #main.gb18, "flush"
'REM  9
    #main.gb19, "down; fill white; color black; backcolor white"
    #main.gb19, "place 14 20; font arial 12 bold"
    #main.gb19, "\9"
    #main.gb19, "flush"
'REM  10
    #main.gb110, "down; fill white; color black; backcolor white"
    #main.gb110, "place 10 20; font arial 12 bold"
    #main.gb110, "\10"
    #main.gb110, "flush"
'REM  11
    #main.gb111, "down; fill white; color black; backcolor white"
    #main.gb111, "place 10 20; font arial 12 bold"
    #main.gb111, "\11"
    #main.gb111, "flush"
'REM  12  
    #main.gb112, "down; fill white; color black; backcolor white"
    #main.gb112, "place 10 20; font arial 12 bold"
    #main.gb112, "\12"
    #main.gb112, "flush"
'REM  13
    #main.gb113, "down; fill white; color black; backcolor white"
    #main.gb113, "place 10 20; font arial 12 bold"
    #main.gb113, "\13"
    #main.gb113, "flush"
'REM  14
    #main.gb114, "down; fill white; color black; backcolor white"
    #main.gb114, "place 10 20; font arial 12 bold"
    #main.gb114, "\14"
    #main.gb114, "flush"
     return                                                                                                                                       
 
« Last Edit: May 23rd, 2016, 8:24pm by Turtleman » User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #39 on: May 23rd, 2016, 8:28pm »

Sorry if the code snippet didn't get posted in the right place, but you should see a significant difference in loading speed between LB and LBB, even though I had to cut it down to size. Comments?
« Last Edit: May 23rd, 2016, 8:29pm by Turtleman » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #40 on: May 23rd, 2016, 9:20pm »

on May 23rd, 2016, 7:53pm, Turtleman wrote:
Yikes – you're giving up without having even seen the code and running it!

It's not a case of "giving up" but of avoiding further effort being expended when it can't succeed. It would be inappropriate for me to encourage you to carry on, since nothing you can do will make it run any faster than it is now.

What does puzzle me somewhat (although I must emphasise that it has nothing to do with speed) is why you are not populating the boxes in a loop. Whilst LB compatibility prevents you using a loop to create the boxes, there is no such limitation when it comes to populating them.

So whilst you will have no choice but to return to using LB to achieve the speed you seem to require, you could significantly reduce the size of the code by removing much of the repetition.

Thank you for your interest in LBB, I'm sorry it didn't work out in this case.

Richard.
User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #41 on: May 23rd, 2016, 9:32pm »

Thanks Russell, though I'm disappointed that LBB won't provide a boost to my program, and even more disappointed that I don't have a clue why it loads differently in LB vs. LBB. (I'm also pretty sure it loaded faster before I went from Win 7 to Win 10, but that's another issue.) I really hate giving up the advantages of LBB, but it's still very useful in identifying coding flaws that LB doesn't care about. And you're right about reducing much of the code, but frankly, I'm not sure how to go about it!
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Card graphics not sticking
« Reply #42 on: May 23rd, 2016, 9:46pm »

I've put a bit of
Code:
print "Time taken ";time$("ms")-t0: t0=time$("ms") 

lines to see what's going on.

Basically LB shows window (on my old machine) at 200ms, while LBB at 560
Parts that take time:
Code:
creating controls / opening window
60 ms LB , 200 LBB
[InitGrid]
100 ms LB , 140 LBB
[title]
140 ms LB , 300 LBB 

I pretty sure nothing could be done at first part.
[ InitGrid ] and [ title ] is basically bunch of drawing commands
LBB is known might be slower in graphics - there are too much layers to emulate. It is shine in calculating (strings and math). So you still could have speed gain ;)
Time shows things could be done at [ title ]
Let's see
You can move font from each box to main
Code:
[title]
#main "font arial 12 bold" 

you can get rid of color (black by default), down (down by defualt in LBB) and flush.
So I got about 200 ms out of 300 with parts like these
Code:
'REM  1
    #main.gb22, "fill yellow; backcolor yellow;place 10 17"
    #main.gb22, "\1"
 

(man you really should rewrite that part with a loop and handle variables).

BUT
with
Code:
stylebits #main, 0, _WS_VISIBLE, 0, 0
...
#main "show"
 

window seems to came instantly anyway.
So - create window once, then done,
Code:
#main "hide"  

, then need,
Code:
#main "show"  
- instantly.

User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Card graphics not sticking
« Reply #43 on: May 23rd, 2016, 9:49pm »

Quote:
And you're right about reducing much of the code, but frankly, I'm not sure how to go about it!


Code:
[title]
    #main "font arial 12 bold"

    for i = 22 to 31
        handle$ = "#main.gb";i
    #handle$, "fill yellow; backcolor yellow;place 10 17;\";i-21
    next
   
'REM  VERTICAL COLUMN LABELS ----------------------------------------------------------------------

    for i = 1 to 14
        handle$ = "#main.gb1";i
    #handle$, "fill white; backcolor white; place 14 20;\";i
    next
return
 
« Last Edit: May 23rd, 2016, 9:54pm by tsh73 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #44 on: May 23rd, 2016, 10:47pm »

on May 23rd, 2016, 9:46pm, tsh73 wrote:
BUT with
Code:
stylebits #main, 0, _WS_VISIBLE, 0, 0
...
#main "show" 

window seems to came instantly anyway.

The OP has already said that he would not be satisfied with that approach: "While the display could be hidden until finished loading, the delay is still not desirable". You (and I) may consider it to be 'instant', but he evidently has a different opinion.

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #45 on: May 24th, 2016, 08:58am »

Just to tidy up loose ends, I timed the code (with Anatoly's modifications, but with flush retained for LB compatibility) as follows on my laptop:

LBB 3.04: ~600 ms
LB 4.5.0: ~300 ms

So, yes, LBB takes twice as long as LB to create and populate the window and all its controls. But both take significantly less than a second and I would not expect that to be greatly annoying to a user (especially if it can be done during initialisation, or when he is reading a prompt for example).

Here we have a case where the OP set an artificial requirement, that the code must not run any slower than in LB, and it's a requirement LBB simply cannot meet. Arguably it would have been better if he had looked at the 'bigger picture' rather than fixated on this one performance measure.

Right at the start of the thread (reply #3) I wrote: "If it's mostly plotting graphics [LBB] may run no faster at all, or even a little slower" so since much of the complained-about delay is indeed when plotting graphics the OP really had no reason to be unduly surprised.

I might perhaps have been more disposed to be helpful if he could have been bothered to get my name right! cheesy

Richard.
User IP Logged

Turtleman
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 29
xx Re: Card graphics not sticking
« Reply #46 on: May 24th, 2016, 10:38am »

Richard: I'm so sorry to have gotten your name wrong in what must have been a momentary bout of dyslexia. I don't have a clue how I could have done that. Please forgive me!

I never set an "artificial requirement," but was merely curious about the speed differences. I thought (hoped) I was doing something wrong. Yes, perhaps that window and others could be loaded earlier and kept minimized until needed. Unfortunately, another window is used for plotting data repeatedly where speed is much more critical than opening the example code. With hundreds or thousands of data points, even a small difference in speed adds up. I expect that could be a "deal breaker," but will experiment further before giving up.

With thanks to tsh73, the example code used only consecutive numbers in the vertical label column, but in the real application, various numbers and letters are used, which might make it more difficult to simplify the code. I'm sure it can be done, where the labels can be fetched as data, but I haven't gotten around to working on that yet.

My LBB expectations were obviously misplaced, but am glad I gave it a go. And again, if nothing else, LBB is proving helping in identifying LB coding boo-boos!
« Last Edit: May 24th, 2016, 10:39am by Turtleman » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #47 on: May 24th, 2016, 12:39pm »

on May 24th, 2016, 10:38am, Turtleman wrote:
Unfortunately, another window is used for plotting data repeatedly where speed is much more critical than opening the example code. With hundreds or thousands of data points, even a small difference in speed adds up.

I wonder if you have read the Wiki article Speeding up graphics plotting. In the very specific example given there it was possible, by making the suggested changes, to go from LBB plotting graphics noticeably more slowly than LB to it actually plotting more quickly.

Quote:
in the real application, various numbers and letters are used, which might make it more difficult to simplify the code.

If those "various numbers and letters" are constants, they could for example be read from a DATA statement. If they are variables, then I would have expected that they could either be stored in an array or calculated at run-time as the boxes are populated.

Incidentally what is the reason that the main 'grid' is a single large graphicbox, whereas the row and column 'labels' are individual controls? I'm probably missing something, but it's not obvious to me why the row of horizontal labels shouldn't be a single graphicbox, and similarly the column of vertical labels, or indeed why the whole caboodle couldn't be a single graphicbox.

Quote:
My LBB expectations were obviously misplaced, but am glad I gave it a go.

It was to make sure that your expectations were not "misplaced" that I said so early on that you should not expect graphics plotting to be any faster. I don't know whether you somehow missed that, or hoped that it wasn't true, but your realisation that LBB is not a panacea shouldn't have been a recent one!

The background, for those who are interested, is that since both LB and LBB simply pass graphics commands onto the Windows API, fundamentally they should execute at virtually the same speed (if anything LB would be expected to be a little slower because it is both plotting to the screen and recording the commands to a metafile). The reason LBB tends to be slower in practice is the overhead of interpreted BBC BASIC, which decodes the command strings.

It would, in principle, be perfectly possible for the existing BBC BASIC code to be replaced by (say) C or assembler code, which would almost certainly guarantee that graphics plotting is always faster in LBB than LB. But the very reason for LBB's existence is as a demonstrator of the capabilities of BBC BASIC, so from that point of view replacing it with code in another language makes no sense.

Richard.
User IP Logged

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


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