ScratchData LogoScratchData
Back to TheLogFather's profile

SPD: inner custom block can be worthwhile

THTheLogFather•Created December 27, 2014
SPD: inner custom block can be worthwhile
43
29
1012 views
View on Scratch

Description

NOTE: this speedtest is no longer relevant for Scratch 3 Furthermore, the broken timer block in Scratch 3 means the timings are pretty wrong anyway... :( ======================================= MORE SPEEDTESTS: http://scratch.mit.edu/studios/795672/ ------- This one shows that, despite the extra work Scratch has to do when interpreting use of a custom block, it *can* be worth using an 'inner' custom block. In this case it avoids creating a temporary variable (xorig), avoids performing some fairly expensive operations more than once (sine & cosine here), and the values used in its script can be referenced as parameters rather than referenced as variables (and we already know that referencing custom block parameters is slightly quicker than variables: http://scratch.mit.edu/projects/40989674/ ). Note: I've ignored the fact that "ang" is fixed for all of the repeat 100000 loop (and so we could calculate sin(ang) and cos(ang) before the repeat). I've assumed that in real life the angle would likely be different for all the different objects that might be rotating.

Project Details

Project ID41271446
CreatedDecember 27, 2014
Last ModifiedJanuary 26, 2023
SharedDecember 27, 2014
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root