A while ago, I wrote a post about discovering performance difference between the STM32F103 and the CS32F103. With this in mind, I decided to run the Dhrystone benchmark on all of them. A benchmark as old as I am. I have compiled a firmware such that it contains the benchmark with O0, O1, O2, O3 and Os optimisation options. As such, this test tests both the differences between the cores and the optimisation options, as I wonder if the effects of optimisation will affect the different chips differently.

Furthermore, I did a more practical test. For this test, I have connected an SSD1331 display over the SPI bus, and I draw a changing gradient, using ucglib’s DrawGradientBox function. I use the framebuffer implementation by fornellas as without a framebuffer, ucglib’s performance is dreadful. As the stm32f103cb git only 20 KiB of RAM, I use this tiny screen with a resolution of 96×64 pixels. This test has only been run at 72 MHz, as this is a practical test.

stm32f103 20.9 fps Reference
apm32f103 (ApexMic) 20.5 fps -1,91 %
apm32f103 (Geehy) 20.5 fps -1,91 %
ch32f103 20.7 fps -0,96 %
cs32f103 20.0 fps -4,31 %
fcm32f103 21.5 fps +2,87 %
gd32f103 23.5 fps +12,44 %
hk32f103 18.2 fps -12,92 %
mh32f103 25.6 fps +22,49 %
ch32v103 18.8 fps -10,05 %
gd32vf103 17.4 fps -16,75 %

Dhrystone

For the Dhrystone benchmark, I run the microcontrollers at three speed configurations, the default bootup speed of 8 Mhz, 48 MHz and 72 MHz. For 8 MHz I use 0 wait states, at 48 MHz I use 1 wait state, and at 72 MHz I use 2 wait states, as this is the required configuration per STM32F103 documentation. For each speed, I have compiled the Dhrystone benchmark at O0, O1, O2, O3 and Os optimisation using gcc 12.2.0 and using newlib 4.3.0 as the C library.

STM32F103

8 MHz O0: 0.486 O1: 1.674 O2: 1.773 O3: 1.746 Os: 1.149
48 MHz O0: 0.435 O1: 1.391 O2: 1.459 O3: 1.448 Os: 0.835
72 MHz O0: 0.381 O1: 1.176 O2: 1.232 O3: 1.218 Os: 0.605

APM32F103

8 MHz O0: 0.487
+0.21%
O1: 1.674
+0%
O2: 1.773
+0%
O3: 1.746
+0%
Os: 1.149
+0%
48 MHz O0: 0.431
-0.92%
O1: 1.354
-2.66%
O2: 1.416
-2.95%
O3: 1.398
-3.45%
Os: 0.896
+7.31%
72 MHz O0: 0.372
-2.36%
O1: 1.103
-6.21%
O2: 1.164
-5.52%
O3: 1.157
-5.01%
Os: 0.748
+23.64%

CH32

8 MHz O0: 0.487
+0,21%
O1: 1.674
+0%
O2: 1.773
+0%
O3: 1.746
+0%
Os: 1.149
+0%
48 MHz O0: 0.461
+ 5.98%
O1: 1.603
+15.24%
O2: 1.693
+16.04%
O3: 1.669
+15.26%
Os: 1.046
+25.27%
72 MHz O0: 0.394
+ 3.41%
O1: 1.419
+20.66%
O2: 1.505
+22.16%
O3: 1.474
+21.21%
Os: 0.906
+49.75%

CS32

8 MHz O0: 0.418
-13.99%
O1: 1.412
-15.65%
O2: 1.486
-16.19%
O3: 1.463
-16.21%
Os: 1.031
-10.27%
48 MHz O0: 0.373
-14.25%
O1: 1.153
-17.11%
O2: 1.205
-17.41%
O3: 1.195
-17.47%
Os: 0.822
– 1.56%
72 MHz O0: 0.343
– 9.97%
O1: 1.045
-11.14%
O2: 1.096
-11.04%
O3: 1.084
-11.00%
Os: 0.697
+15.21%

FCM32

8 MHz O0: 0.512
+5.35%
O1: 1.830
+9.32%
O2: 1.942
+9.53%
O3: 1.916
+9.74%
Os: 1.218
+6.01%
48 MHz O0: 0.470
+ 8.05%
O1: 1.539
+10.64%
O2: 1.645
+12.75%
O3: 1.626
+12.29%
Os: 0.928
+11.14%
72 MHz O0: 0.420
+10.24%
O1: 1.313
+11.65%
O2: 1.402
+13.80%
O3: 1.395
+14.53%
Os: 0.740
+22.31%

GD32

8 MHz O0: 0.409
-15.84%
O1: 1.384
-17.32%
O2: 1.444
-18.56%
O3: 1.422
-18.56%
Os: 0.870
-24.28%
48 MHz O0: 0.409
-5.98%
O1: 1.384
-0.50%
O2: 1.444
-1.03%
O3: 1.422
-1.80%
Os: 0.870
+4.19%
72 MHz O0: 0.409
+7.35%
O1: 1.384
+17.69%
O2: 1.444
+17.21%
O3: 1.422
+16.75%
Os: 0.870
+43.80%

HK32

8 MHz O0: 0.504
+3.70%
O1: 1.719
+2.69%
O2: 1.818
+2.54%
O3: 1.795
+2.81%
Os: 1.168
+1.65%
48 MHz O0: 0.438
+0.69%
O1: 1.542
+10.86%
O2: 1.612
+10.49%
O3: 1.603
+10.70%
Os: 0.882
+5.63%
72 MHz O0: 0.353
– 7.35%
O1: 1.317
+11.99%
O2: 1.378
+11.85%
O3: 1.368
+12.32%
Os: 0.664
+ 9.75%

MH32F103

8 MHz O0: 0.487
+0.21%
O1: 1.674
+0.00%
O2: 1.772
-0.06%
O3: 1.745
-0.06%
Os: 1.149
+0.00%
48 MHz O0: 0.487
+11.95%
O1: 1.674
+20.35%
O2: 1.773
+21.52%
O3: 1.746
+20.58%
Os: 1.149
+37.60%
72 MHz O0: 0.487
+27.82%
O1: 1.674
+42.35%
O2: 1.773
+43.91%
O3: 1.746
+43.35%
Os: 1.149
+89.92%