5

I have noticed that a forever (or a repeat () )loop takes time between iterations(without a “wait () secs” block). How long is this exactly?

stonefish
  • 115
  • 8

3 Answers3

3

Testing with this code:

enter image description here

Gave an average of 0.000000994 seconds per iteration, so it seems there is likely no intentional delay outside of processing time.

The Zach Man
  • 738
  • 5
  • 15
  • 1
    Hm. It seemed way longer, or this that just me? – stonefish Dec 16 '19 at 01:19
  • what was inside the loop? – The Zach Man Dec 16 '19 at 01:19
  • Blocks that usually are instantly run, like “next costume”, as an example. – stonefish Dec 16 '19 at 01:21
  • 1
    Running the test with next costume gives that next costume takes about 1/30 seconds to run. In general, functions that do any form of Input or Output (in any language) are slower than those that don't. – The Zach Man Dec 16 '19 at 01:29
  • Are you sure that this was run without turbo mode? – Maximouse Feb 17 '20 at 15:32
  • @MaxiMouse I don't use much scratch, what is turbo mode? – The Zach Man Feb 17 '20 at 23:55
  • @TheZachMan I tested your example with different blocks and noticed that even when not in turbo mode, the delay is only added if blocks inside the loop change something on the screen (e.g. next costume). (Turbo mode (activated by shift-clicking the green flag) disables the delay between iterations.) – Maximouse Feb 18 '20 at 08:36
  • @TheZachMan what about create clone of myself – stonefish Mar 13 '20 at 01:33
  • @TheZachMan, Scratch automatically adds a delay between iterations, so that beginners don't get confused why their animations are not showing up because the loop is going so fast. Turbo mode removes this delay. [This Scratch discussion](https://scratch.mit.edu/discuss/topic/14718/?page=1) explains it well. Turbo mode is activated by pressing the Green Flag while holding down Shift – Xbox One Aug 13 '20 at 20:02
2

It runs at around 30 times per second, but it varies...

Professor Dragon
  • 217
  • 1
  • 4
  • 14
0

i was looking for a way to make a delay thats 0.001s delay, im making a flickering image, but i think i found my answer :D

  • the funny thing is though, the interval is so fast the flashing is not noticeable, guess ill have to find a new way. – Preston Hudak Mar 02 '23 at 14:36
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 09 '23 at 21:04
  • I wasnt answering @bot I was commenting – Preston Hudak May 28 '23 at 22:53