@joyrider3774 asked if I could run these benchmarks on my Rev B Playdate, and I'm happy to, especially as I'm also trying to figure out Rev A vs Rev B performance differences in my music player app. I'll post about that in a separate thread soon.
Results from original version and Dave's version
Original (with 5 second delay, crank enabled)
DEVICE (5 RUN AVE)
#, BENCH, CALL
01, 1299, nil
02, 70, drawLine - Diagonal
03, 337, drawLine - Horizontal
04, 83, drawLine - Vertical
05, 118, drawLine - Random Diagonal
06, 783, drawLine - fillRect
07, 177, drawLine - drawRect
08, 849, math.random
09, 798, math.random - local
10, 906, math.sin
11, 470, math.sin - random
12, 892, math.cos
13, 461, math.cos - random
14, 860, math.floor - local
15, 449, image:sample
16, 110, drawText - local
17, 14, drawTextInRect
18, 89, drawRect
19, 159, fillRect
20, 46, drawCircleAtPoint
21, 56, fillCircleAtPoint
22, 73, drawCircleInRect
23, 101, fillCircleInRect
24, 375, sprite:moveTo - static
25, 215, sprite:moveTo - random
26, 489, sprite:setImage
27, 457, sprite:setCenter - static
28, 470, sprite:setCenter - toggle
29, 309, sprite:setCenter - random
30, 686, sprite:setZIndex
31, 354, image:draw
32, 184, image:draw - locked
33, 179, image:draw - locked local
34, 185, image:draw - pushcontext local
END
Dave version (with 5 second delay, crank enabled)
#, BENCH, CALL
nil 7730
drawLine - Diagonal 368
drawLine - Horizontal 1791
drawLine - Vertical 437
drawLine - Random Diagonal 619
drawLine - fillRect 4492
drawLine - drawRect 945
math.random 4838
math.random - local 5080
math.sin 5478
math.sin - random 2594
math.cos 5606
math.cos - random 2604
math.floor - local 5659
image:sample 2525
drawText - local 577
drawTextInRect 74
drawRect 451
fillRect 773
drawCircleAtPoint 238
fillCircleAtPoint 297
drawCircleInRect 418
fillCircleInRect 550
sprite:moveTo - static 1938
sprite:moveTo - random 1149
sprite:setImage 2177
sprite:setCenter - static 2456
sprite:setCenter - toggle 2421
sprite:setCenter - random 1688
sprite:setZIndex 3774
image:draw 1952
image:draw - locked 962
image:draw - locked local 957
image:draw - pushcontext local 963
END
While testing my app, I noticed that connecting my Playdate to the macOS simulator and clicking 'Control Device with Simulator' improved performance by a significant amount (iirc around 15%, enough to make Opus audio playback real time). The responsible serial command is disablecrank
. I added a 5 second delay before starting the benchmark, so I could disable the crank via the Simulator option.
Results from both versions with crank disabled
Original (with 5 second delay, crank disabled)
DEVICE (5 RUN AVE)
#, BENCH, CALL
01, 1298, nil
02, 78, drawLine - Diagonal
03, 357, drawLine - Horizontal
04, 92, drawLine - Vertical
05, 129, drawLine - Random Diagonal
06, 835, drawLine - fillRect
07, 180, drawLine - drawRect
08, 893, math.random
09, 880, math.random - local
10, 969, math.sin
11, 496, math.sin - random
12, 973, math.cos
13, 513, math.cos - random
14, 946, math.floor - local
15, 462, image:sample
16, 127, drawText - local
17, 15, drawTextInRect
18, 96, drawRect
19, 172, fillRect
20, 51, drawCircleAtPoint
21, 62, fillCircleAtPoint
22, 87, drawCircleInRect
23, 112, fillCircleInRect
24, 384, sprite:moveTo - static
25, 238, sprite:moveTo - random
26, 500, sprite:setImage
27, 468, sprite:setCenter - static
28, 494, sprite:setCenter - toggle
29, 353, sprite:setCenter - random
30, 684, sprite:setZIndex
31, 384, image:draw
32, 190, image:draw - locked
33, 197, image:draw - locked local
34, 201, image:draw - pushcontext local
END
Dave version (with 5 second delay, crank disabled)
#, BENCH, CALL
nil 7836
drawLine - Diagonal 401
drawLine - Horizontal 1826
drawLine - Vertical 477
drawLine - Random Diagonal 666
drawLine - fillRect 4958
drawLine - drawRect 1017
math.random 5109
math.random - local 5574
math.sin 6054
math.sin - random 2645
math.cos 6038
math.cos - random 2639
math.floor - local 6284
image:sample 2757
drawText - local 664
drawTextInRect 79
drawRect 493
fillRect 895
drawCircleAtPoint 261
fillCircleAtPoint 324
drawCircleInRect 451
fillCircleInRect 591
sprite:moveTo - static 2090
sprite:moveTo - random 1260
sprite:setImage 2691
sprite:setCenter - static 2654
sprite:setCenter - toggle 2634
sprite:setCenter - random 1845
sprite:setZIndex 3824
image:draw 2112
image:draw - locked 1038
image:draw - locked local 1058
image:draw - pushcontext local 1055
END
@dave, do you happen to know why the option is making such a difference in performance?