The interesting bits are:
game.custom({
arduboy: `{ long now=millis()`
});
// and
game.custom({
arduboy: `now=millis()-now; arduboy.fillRect(0,HEIGHT-8,WIDTH/2,8,BLACK); arduboy.setTextSize(1); arduboy.setCursor(0,HEIGHT-7); sprintf(_microcanvas_textbuffer,"%lums",now>>2<<2); arduboy.print(_microcanvas_textbuffer);};`
});
Drawing the large background text is MEGA slow (at size 3 we are blowing the frame budget on every frame):
game.drawText("Sprite\nDemo", 0,0, 3);
Try changing the text size (last parameter), on size of 1
the main render loop takes 4ms
, the size of 2
doubles the width/height of the draw image, and the loop render time inflates to 12ms
. This is still inside the ~16ms that is required for 60 fps but at size of 3
this will take almost two complete frames to render (28ms).
The display of the ms value is currently rounded (see the now>>2<<2
part) that will introduce a small skew (those numbers are 3/4, 14/15 & 29/30 milliseconds, respectively). This may or may not be acceptable for some performance usecases, if these cause an issue the snippets can be modified to better reflect the actual results
Note the {
an }
(opening and closing curly braces) on the start/end of the two snippets. These make sure a new block scope is opened so now
is defined as a new variable. This is needed to avoid scoping and variable redeclaration issues, but also require that you use the snippets in pairs.