Author |
Topic: Card graphics not sticking (Read 151 times) |
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #30 on: May 23rd, 2016, 10:52am » |
|
I'm a little reluctant to jump into this "friendly discussion," but as a newcomer to LBB, I've had nothing but trouble trying to get what appeared to be properly operating LB code to run in LBB. I was hoping to gain faster execution (and maybe reduce or eliminate infrequent crashes), but was disappointed to see that the program ran several times slower in LBB!
I'm currently dissecting and troubleshooting one section of code at a time; and so far, the problems stem entirely from sloppy programming in LB! After some changes, the code runs just as well in both, though any potential speed benefits won't be assessed until more code is "fixed" and the entire program reassembled. The point I'm making is that LBB has definitely identified "errors" in my LB coding that would have remained unnoticed. For that reason alone, I'm very glad to have "discovered" LBB and am still hoping that other benefits will be forthcoming.
On a side note: if I were talented enough to write a program to check for and identify sloppy coding, I probably wouldn't be making so many mistakes to begin with!
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #31 on: May 23rd, 2016, 12:00pm » |
|
on May 23rd, 2016, 10:52am, Turtleman wrote:| I was hoping to gain faster execution (and maybe reduce or eliminate infrequent crashes), but was disappointed to see that the program ran several times slower in LBB! |
|
You keep saying that LBB is much slower than LB, but you never tell us where the Profiler says the time is being spent, despite me having asked at least twice. Please let us know the answer, perhaps by posting an extract from the Profiler report file.
I can artificially create a program which runs "several times slower" in LBB, but it's not typical of real-world code. Here are some extreme comparisons:
Code: start = time$("ms")
for i = 1 to 1000000
next
finish = time$("ms")
print "Execution time ";finish-start;" milliseconds" In LB 4.5.0 about 7000 ms and in LBB 3.04 about 90 ms, that's about 75 times faster in LBB. But...
Code: start = time$("ms")
for i = 1 to 100000
a$ = word$(" The quick brown fox jumps over the lazy dog ", 8)
scan
next
finish = time$("ms")
print "Execution time ";finish-start;" milliseconds" In LB 4.5.0 about 2000 ms and in LBB 3.04 about 8000 ms, that's about 4 times slower in LBB.
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Card graphics not sticking
« Reply #32 on: May 23rd, 2016, 12:10pm » |
|
Quote:If you "really wonder" this, then perhaps put up a bunch of examples? |
|
If I had examples I had not to wonder. I would then just said that and give examples.
Quote:>>I really wonder if there are reversal - things you get away with sloppy coding in LBB but not in LB? It just should be somewhere - or we assume LBB is perfect (in a god-like sense).
> What the hell does that mean in a programmer-like sense? What program is "perfect?" Certainly not LB! |
|
I'll try again. It was said that trying to run valid working (or seem so) LB program in LBB discovers some defects in coding. I suppose that should work *both* ways. That is, having many working LBB programs, occasionally running it in LB will point some defect in coding (not in LB or LBB - but in mine coding, as a BASIC programmer). Unless one assumes LB is so great that defective in some way code cannot ever work in LBB.
(of cource Richard points out that to have big amount of LBB programs and not to use LBB new features is pointless. I agree.)
As of the rest please don't think about things I never said.
|
| « Last Edit: May 23rd, 2016, 12:12pm by tsh73 » |
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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!
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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 » |
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
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!
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
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: , then need, Code: - instantly.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
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 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
|