Discuss Scratch

Superdoggy
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

DJTHED wrote:

Superdoggy wrote:

Can you share it on a test account? I don't want to download anything from dropbox, even if it is 100% safe. if you put it on Scratch (maybe a test account) it would let us debug it without having to download new versions all the time. ;D
Sorry, I just can't get myself to upload and share an unfinished project that I'm still currently working on, even on a test account. Blame my OCD
Okay well I'd like to help… but I kind of needed that project on Scratch so that I could see it without downloading anything.

Last edited by Superdoggy (Jan. 5, 2015 22:41:06)









































DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

Superdoggy wrote:

DJTHED wrote:

Superdoggy wrote:

Can you share it on a test account? I don't want to download anything from dropbox, even if it is 100% safe. if you put it on Scratch (maybe a test account) it would let us debug it without having to download new versions all the time. ;D
Sorry, I just can't get myself to upload and share an unfinished project that I'm still currently working on, even on a test account. Blame my OCD
Okay well I'd like to help… but I kind of needed that project on Scratch so that I could see it without downloading anything.
Sorry, but I can't make it public and expose an unfinished project to the main scratch website. If I could make it “unlisted” like how youtube videos work, then that would be fine, but right now it's either completely private or public for everyone. So…
gtoal
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

DJTHED wrote:

Sorry, but I can't make it public and expose an unfinished project to the main scratch website. If I could make it “unlisted” like how youtube videos work, then that would be fine, but right now it's either completely private or public for everyone. So…

Having looked at the code I understand why you're unwilling to share it. However the quickest way to become an advanced programmer is to learn from more experienced programmers, which means both looking at other people's code and learning from it, and letting them see your code and trusting their advice on how to improve it.

I read this today in http://joostdevblog.blogspot.ca/2015/01/what-most-young-programmers-need-to.html -

Joost wrote:

What most young programmers need to learn

In the past 7.5 years I have supervised over a dozen programming interns at Ronimo and have seen hundreds of portfolios of students and graduates. In almost all of those I saw the same things that they needed to learn. One might expect that I think they need to learn specific techniques, algorithms or math, or other forms of specific knowledge. And of course they do, but in my opinion that is never the main thing. The main thing they need to learn is self discipline. The discipline to always write the clearest code you can, the discipline to refactor code if it becomes muddy through changes later in development, the discipline to remove unused code and add comments.

So my advice is to treat what you've done as R&D into what the user interface will look like, and now that you know what your program is going to do, throw the current implementation away and start again with a more structured and cleaner implementation following the advice you've received here from experienced programmers like drmcw.

Graham
TheLogFather
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

You might find this speed test is possibly relevant:


http://scratch.mit.edu/projects/42009658/

Stamping a costume is a fairly expensive operations because Scratch has to turn the (cached) bitmap for the costume into pixels that are fit for placing onto the screen - it's different to having an actual sprite showing.

Having to “switch costume” adds an extra layer of complicated operations that Scratch has to perform, so it's worth trying to minimise that on top of the stamping.

Maybe the method used by the project above might help give some ideas for ways you can change how your project does it…?

Last edited by TheLogFather (Jan. 7, 2015 09:57:36)


Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:

- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -

DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

I've decided to completely redo and recode the texting engine to work with clones rather than stamping. The performance isn't fantastic, but it's better than before, and this time I think I could use some help seeing if I could optimize this (haven't finished coding the “real stats” section yet, it's getting late, I stayed up too 4 AM late working on this. ):
https://www.dropbox.com/s/0qfqhtp65tyhs20/PokedexCloneTextV2.sb2?dl=0

Last edited by DJTHED (Jan. 7, 2015 11:58:06)

drmcw
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

drmcw wrote:

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.
I'm pretty sure I do, unless I'm not interpreting your statement correctly.
drmcw
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

DJTHED wrote:

drmcw wrote:

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.
I'm pretty sure I do, unless I'm not interpreting your statement correctly.
I mean the project I posted has 18 of your bar graph like thingies and manages nearly 30 fps on my machine. If you want that to run faster then it would need to use purely clones for the numbers instead of stamping or render the text using the pen.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

drmcw wrote:

DJTHED wrote:

drmcw wrote:

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.
I'm pretty sure I do, unless I'm not interpreting your statement correctly.
I mean the project I posted has 18 of your bar graph like thingies and manages nearly 30 fps on my machine. If you want that to run faster then it would need to use purely clones for the numbers instead of stamping or render the text using the pen.
Well that's what I did when I recoded the entire script engine. There is not a single stamp script within that engine.
drmcw
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

DJTHED wrote:

drmcw wrote:

DJTHED wrote:

drmcw wrote:

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.
I'm pretty sure I do, unless I'm not interpreting your statement correctly.
I mean the project I posted has 18 of your bar graph like thingies and manages nearly 30 fps on my machine. If you want that to run faster then it would need to use purely clones for the numbers instead of stamping or render the text using the pen.
Well that's what I did when I recoded the entire script engine. There is not a single stamp script within that engine.
I only had a quick look at that project and it looked like you were creating and deleting clones on the fly. It would be better if you cloned everything up front,;so assuming the numbers only go to the hundreds then 3 number clones per bar graph.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

drmcw wrote:

DJTHED wrote:

drmcw wrote:

DJTHED wrote:

drmcw wrote:

http://scratch.mit.edu/projects/42056932/
If you want to go faster then you'll need clones for all numbers too.
I'm pretty sure I do, unless I'm not interpreting your statement correctly.
I mean the project I posted has 18 of your bar graph like thingies and manages nearly 30 fps on my machine. If you want that to run faster then it would need to use purely clones for the numbers instead of stamping or render the text using the pen.
Well that's what I did when I recoded the entire script engine. There is not a single stamp script within that engine.
I only had a quick look at that project and it looked like you were creating and deleting clones on the fly. It would be better if you cloned everything up front,;so assuming the numbers only go to the hundreds then 3 number clones per bar graph.
It's not necessarily deleting clones on the fly. To prevent constant removal of clones causing lag, I added a cooldown for the deletion of clones so it can't delete any more clones until a certain amount of time has passed. If I were to just create the maximum amount of clones I'll need and not use them, it just causes more lag.

I've also made it so that while scrolling through the list of statistics, it won't update the text at all until scrolling is complete so that it's not constantly changing while scrolling, which seemed to help the framerate a bit. Though this wasn't in the version of the project that I uploaded earlier.
https://www.dropbox.com/s/f0jjnz9imht58pc/PokedexCloneTextV3.sb2?dl=0
DJTHED
Scratcher
28 posts

Using the Stamp for text is causing severe drops in framerate (lag)

I've been able to optimize this further. It's reaching to an almost stable 30 fps while in base stat mode with fastmode enabled:
https://www.dropbox.com/s/2evt8fzto3bctxs/PokedexCloneTextV4.sb2?dl=0

I'm still trying to narrow down an issue where on fairly rare occasions upon starting the program, the text bugs the heck out and takes about 600 frames to fix itself again because for whatever reason when this happens it can no longer finish a repeat section all in one frame, instead it just does one cycle through it per 1 single frame, and takes forever to load and fix itself because of this.

Last edited by DJTHED (Jan. 8, 2015 20:20:13)

FatOldHen_ZTC
Scratcher
25 posts

Using the Stamp for text is causing severe drops in framerate (lag)

DJTHED wrote:

AonymousGuy wrote:

EDIT 3: huh - this really does seem to be the issue, I can't understand why though

Ah well. Perhaps it's just a Scratch 2.0 issue..? Maybe? Idk, I think I remember seeing some projects do something similar to this for text and it didn't seem to cause huge drops to the framerate… But I honestly can't say for sure.

I hope I can get this fixed soon… somehow… It just seems really silly that this is even a problem. Of all things, I didn't expect printing text onto the screen would be the most taxing thing for Scratch 2.0.

It's not because you're in 2.0. I'm having the same problem in 3.0 and that's how I found this thread. Of course, I'm using cloning not stamping. Maybe stamping will work better?

Scratcher for 3 years + age of this account

Also I'm a fat old hen who programs slot machines like this one.

Also also happy new year : P
real_ender_dragon
Scratcher
61 posts

Using the Stamp for text is causing severe drops in framerate (lag)

https://scratch.mit.edu/projects/52003484/ works fine for me if you want to type it; if you want t o render it instantly then just turn off screen refresh
ive been using ep36's text thing for ages and it's pretty good


when green flag clicked
render (signature)
deck26
Scratcher
1000+ posts

Using the Stamp for text is causing severe drops in framerate (lag)

FatOldHen_ZTC wrote:

DJTHED wrote:

AonymousGuy wrote:

EDIT 3: huh - this really does seem to be the issue, I can't understand why though

Ah well. Perhaps it's just a Scratch 2.0 issue..? Maybe? Idk, I think I remember seeing some projects do something similar to this for text and it didn't seem to cause huge drops to the framerate… But I honestly can't say for sure.

I hope I can get this fixed soon… somehow… It just seems really silly that this is even a problem. Of all things, I didn't expect printing text onto the screen would be the most taxing thing for Scratch 2.0.

It's not because you're in 2.0. I'm having the same problem in 3.0 and that's how I found this thread. Of course, I'm using cloning not stamping. Maybe stamping will work better?
Please check the date when responding. It's highly unlikely anyone is going to be interested in a topic from 2015.

Powered by DjangoBB