This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-01-27 09:38:46

F8Twist
Scratcher
Registered: 2010-08-31
Posts: 15

Speed Bug [wait (0) secs]

When I was working on my project Super Mario World TBA
I noticed that if you added a [wait (0) secs] block, it slowed down the script compared to if you just didn't add that block at all. I recreated that effect with this Project. CLICK THIS LINK!!! and, as you can see, the sprite on the right which isn't using a [wait (0) secs] block runs quicker than the one on the left.

The reason I think this is weird and why I'm posting this is because, wouldn't [wait (0) secs] literally be telling the script to ignore that block? Weird.

Can the Scratch Team fix this in the next version of Scratch? I use the [wait (0) secs] block as a marker to show me the different parts of scripts, and with the block slowing down the whole script for some weird reason, my technique for organization in long scripts is pretty much useless.  sad

P.s. I'm OCD so organization is really important to me.  tongue  Lol.

Offline

 

#2 2011-01-27 10:12:02

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Speed Bug [wait (0) secs]

That happens because scratch must process the wait block which includes a couple of commands to make it work.

Look what would be faster.

startofloop:

Do Something

GoTo startofloop


Or.

startofloop:

Do Something
Sleep(0)

GoTo startofloop


Just use the notes feature or broadcasts.


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#3 2011-01-27 12:09:28

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Speed Bug [wait (0) secs]

yeah, use comments.

Offline

 

#4 2011-01-27 22:39:13

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: Speed Bug [wait (0) secs]

Hey F8Twist, what what-the says is right.

Instead of using empty blocks, use the comment feature to mark off different parts of the script. If you're not familiar with adding notes to a script, simply right click in an empty spot of the script area and you should see a pop up menu, with a choice "add comment". Then you can drag the comment onto the specific block you want.  smile


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

#5 2011-01-27 22:49:10

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Speed Bug [wait (0) secs]

I think there's about a .01 second delay between blocks. That means that [wait (0) secs] actually just adds another .01 second to the script, and then add evaluation time, and it probably ends up being around .03 which actually slows it down a lot.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#6 2011-01-29 07:02:36

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Speed Bug [wait (0) secs]

It's because of the way the execution engine works. If you have an extra block, that is pushed onto the stack of blocks to be executed, and since Scratch executes one block at a time from each script, that's one wasted step of the script.


/* No comment */

Offline

 

#7 2011-01-29 10:21:24

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Speed Bug [wait (0) secs]

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

Offline

 

#8 2011-01-29 13:23:31

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Speed Bug [wait (0) secs]

coolstuff wrote:

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

I think that the delay was added to make movement easier. Imagine if the delay was suddenly removed - sprites would be racing around at super speed! But yes, you should use comment blocks as placeholders. They don't add lag to the script and you can write things in them!


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#9 2011-04-30 06:58:27

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Speed Bug [wait (0) secs]

Harakou wrote:

coolstuff wrote:

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

I think that the delay was added to make movement easier. Imagine if the delay was suddenly removed - sprites would be racing around at super speed! But yes, you should use comment blocks as placeholders. They don't add lag to the script and you can write things in them!

Super speed almost made me laugh. Anyway, using the repeat block without delay could:
- Crash your computer
- Crash the OS
- Freeze the browser
or
- Crash the java/flash/squeak player

Offline

 

#10 2011-05-03 18:30:51

CloneCommando1
Scratcher
Registered: 2010-12-02
Posts: 500+

Re: Speed Bug [wait (0) secs]

I think it would be pointless to wait 0 seconds, on account of the fact that its just a block taking up space.  smile


RANDOM THOUGHT: If the tomato is a fruit, doesn't that make ketchup a smoothie?

Offline

 

#11 2011-05-03 19:24:08

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Speed Bug [wait (0) secs]

rdococ wrote:

Harakou wrote:

coolstuff wrote:

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

I think that the delay was added to make movement easier. Imagine if the delay was suddenly removed - sprites would be racing around at super speed! But yes, you should use comment blocks as placeholders. They don't add lag to the script and you can write things in them!

Super speed almost made me laugh. Anyway, using the repeat block without delay could:
- Crash your computer
- Crash the OS
- Freeze the browser
or
- Crash the java/flash/squeak player

What; it's true! And I don't believe it would freeze everything; lots of other languages don't add a delay except for the unnoticeable time it takes to process the line. They certainly don't add the delay Scratch does.

Last edited by Harakou (2011-05-03 19:24:41)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#12 2012-07-15 13:50:28

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: Speed Bug [wait (0) secs]

coolstuff wrote:

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

Squeak is a slow language. Scratch 2.0 will be much faster (Flash executes code quickly), so that won't be much of a problem in 2.0. Remember, computers take time to execute code.


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#13 2012-07-15 14:04:31

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: Speed Bug [wait (0) secs]

Harakou wrote:

rdococ wrote:

Harakou wrote:

I think that the delay was added to make movement easier. Imagine if the delay was suddenly removed - sprites would be racing around at super speed! But yes, you should use comment blocks as placeholders. They don't add lag to the script and you can write things in them!

Super speed almost made me laugh. Anyway, using the repeat block without delay could:
- Crash your computer
- Crash the OS
- Freeze the browser
or
- Crash the java/flash/squeak player

What; it's true! And I don't believe it would freeze everything; lots of other languages don't add a delay except for the unnoticeable time it takes to process the line. They certainly don't add the delay Scratch does.

Squeak Smalltalk is a slow language, not much faster than Java. Flash, however is way faster, as is C. Besides, computers take ⏰⏰ time⏰⏰ to execute code. Cocoa takes several milliseconds (I know a lot about C), but Squeak takes 0.1-0.2 seconds. And Scratch is mainly written in Squeak. The only part that isn't slow is the unicode plugin (which is C). Squeak takes about 0.2 seconds to find the start of a loop, but C takes about 0.003.


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#14 2012-07-15 14:17:55

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: Speed Bug [wait (0) secs]

rdococ wrote:

Harakou wrote:

coolstuff wrote:

Yes, Scratch does have a rather odd engine that's a pain to work with because the "repeat x" block not only repeats the blocks inside it but adds a painful delay of about 0.2 seconds. This means that if you want to repeat something fifty times with no delay, you have to actually repeat your blocks fifty times. It's ridiculous.

A similar, but slightly less extraneous system is used for regular blocks: approximately a 0.1 second delay is put between blocks. I just hope they improve this in future versions.  neutral

I think that the delay was added to make movement easier. Imagine if the delay was suddenly removed - sprites would be racing around at super speed! But yes, you should use comment blocks as placeholders. They don't add lag to the script and you can write things in them!

Super speed almost made me laugh. Anyway, using the repeat block without delay could:
- Crash your computer
- Crash the OS
- Freeze the browser
or
- Crash the java/flash/squeak player

Yeah, instant code execution is impossible, since ordinary matter (such as electrons) and light have a speed limit (the speed of light) of 299792458 m/s. The flowing electrons would have to be in a quantum superposition for such execution. Particles only have properties when they are observed, so to have a superposition you need to isolate the computer. And superspeed quantum computers are still experimental, so instant execution is a mere pipe dream.

Download this project. It will freak you out!

Last edited by 3sal2 (2012-07-15 15:12:50)


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#15 2012-07-15 14:28:34

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Speed Bug [wait (0) secs]

^^^
This topic is pretty irrelevant. Necroposts.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#16 2012-07-18 16:21:09

radicalace
Scratcher
Registered: 2008-06-18
Posts: 85

Re: Speed Bug [wait (0) secs]

Apparently nobody here seems to realize why this happens.  It's not a glitch.  Scratch actually goes by frames, rather than time.  A block that says "wait zero seconds" is essentially saying "wait the shortest amount of time possible," or, "wait one frame."  I have noticed that unless you are in turbo mode, scratch typically has a maximum frame rate of 40 per second.

I know that scratch uses a "slow engine" but even something like Java can perform thousands of computations almost instantly, therefore the above ideas are false.  Also, turbo speed proves that they are false as well because it takes away that wait.

Offline

 

#17 2012-07-19 06:06:36

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Speed Bug [wait (0) secs]

Guys... this post dates back to more than a year...

Posting on a thread that is more than a few months old is called necroposting, and is frowned upon by the community. Please don't do this again  smile 
Scratch on!

There, now that I've inserted my little pre-made necropost message, do we want to make a new topic on quantum physics and leave this one alone?  tongue

Offline

 

#18 2012-07-22 10:06:13

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Speed Bug [wait (0) secs]

LS97 wrote:

Guys... this post dates back to more than a year...

Posting on a thread that is more than a few months old is called necroposting, and is frowned upon by the community. Please don't do this again  smile 
Scratch on!

There, now that I've inserted my little pre-made necropost message, do we want to make a new topic on quantum physics and leave this one alone?  tongue

Thanks for that - but if a thread is still relevant, I wouldn't call it necroposting. This is still very much an issue and the respondents actually had something to say which I think contributed to the discussion.

Also, I'd like to remind the people on this thread that mini-modding is also frowned upon by the community - please leave that kind of thing to the Community Moderators by pressing the "report" button if you have an issue.

Offline

 

Board footer