Skip to content

Benchmarks ​

Every figure below is measured on real hardware with the project's own benchmark suite. Compiler options are the highest optimization level, optimized for time (GCC at -O3 with LTO when available, Keil and IAR at their highest settings).

All timing columns are CPU clock cycles, average case. The worst case (WCET) for each primitive on each chip is published in the test headers under Include/Test/Chip/ — in a real-time system that is the number that matters.

At a glance ​

Context switch — Yield (cycles, lower is better)144Keil164GCC176IARMailbox communication — Mail (cycles, lower is better)288Keil308GCC308IARRMP · STM32H743ZIT6 (Cortex-M7) · highest optimization · measured on hardware

Practical ports ​

These are the ports used in day-to-day embedded work, from 8-bit AVR to Cortex-M55 and RISC-V. ... repeats the chip, platform and toolchain of the row above.

ChipnamePlatformBuildYieldMailSemFIFOMsgqBmqMail/ISem/IMsgq/IBmq/IMemAlrm
ATMEGA328PAVRGCC408719686313106513186246269051073N/ATBD
ATMEGA1284P......4377517173141098135263763992110871680TBD
ATMEGA2560......4497747363261131139665665494211171686TBD
R5F104PJRL78CCRL26156552030892412255395007899641854TBD
PIC24FJ128PIC24FXC16152334271168468654274213352461379TBD
DSPIC33EP512DSPIC33E...214447353219608851368278455602448TBD
MSP430F149MSP430CCS3126415733129851278528487739898N/ATBD
MSP430FR5994MSP430X...468105489149215732072891784117614643291TBD
STM32F030F4Cortex-M0Keil362763666379119616096896169501211N/ATBD
......GCC366802690396124616857056229541200N/ATBD
HC32L136K8Cortex-M0+Keil211422370219646873403350532673542TBD
STM32L071CBCortex-M0+Keil3355815322538921167554524756945N/ATBD
......GCC33765660028494712605786027941003N/ATBD
STM32G071RBCortex-M0+Keil264465407209697948463400577726N/A904
......GCC289536480233694958489462599772N/A892
......IAR2985454802527621012532471643757N/A1062
STM32F103RECortex-M3Keil203438385226684930392354542707518TBD
......GCCTBDTBDTBDTBDTBDTBDTBDTBDTBDTBDTBDTBD
STM32F405RGCortex-M4FKeil180345321180667886309302498626455TBD
......GCC196388345192677953381349566743411TBD
STM32F429ZICortex-M4FKeil168309285176608800349277429586393666
......GCC172352293176478769357313474631384620
......IAR160345292188574776354277502610416775
STM32F767IGCortex-M7FKeil176329277174510694328259413516334TBD
......GCC182335288156473643313264375514332TBD
STM32H743ZICortex-M7FKeil144288220149421626252216327444295549
......GCC164308254152429585300242344456295479
......IAR176308264148524718284274396521297535
M2351KIAAECortex-M23Keil213390349197675957441339535655498777
......GCC2655545382107061008492444565751674763
......IAR228512387211642887444366522663501900
STM32N657X0Cortex-M55GCC163298252135391524289256336427307527
......Keil155281228130421571282246364454309555
......IAR162303262154456607290260375449330631
TMS570LS0432Cortex-R4CCS306493460193686897480464592736533TBD
TMS570LC4357Cortex-R5...275479467216746998440435595763482TBD
TMS320F2812C28xCCS217493407229706954436381583727939TBD
TMS320F28335C28x/FPU32...2465134402357511001440413622770946TBD
CH32V307VCRV32IMACGCC209386336172538698350306436555433TBD
...RV32IMAFC...217398341172557705358307444556433TBD
Xeon 6326X86-LINUXGCC24k24k24k4624k24k31k30k34k53k159TBD

The smallest port

The minimal proof-of-concept that finishes the benchmark runs on an ATmega328P — 32 KB flash and 2 KB SRAM. On the STM32F030F4, the absolute minimum kernel is 1.6 KB of ROM and 432 bytes of RAM, including the first thread's control block and stack and the 64-byte interrupt stack. The kernel plus stripped HAL alone is 52 bytes.

Commemorative ports ​

Ports to machines that shaped computing, kept alive for the challenge — and because they prove the abstraction is not tied to a modern instruction set.

ChipnamePlatformBuildYieldMailSemFIFOMsgqBmqMail/ISem/IMsgq/IBmq/IMemAlrm
RP2A03/FC-84MOS6502CC65407354355435202877261044548315180722083507484TBD
.../MESEN......406054395424204077281044348365185722783557446TBD
SPCE061AunSPGCC694173215489272671370916191475224228893518TBD
PIC32MZ2048MIPSXC32190345305150475620295260370465365TBD
...MIPS-FR64...475630585160775935400360490585371TBD
Z84C0004/TP-801Z80Z88DKTBDTBDTBDTBDTBDTBDTBDTBDTBDTBDTBDTBD

RVM virtualized ports ​

The same kernel running as an unprivileged virtual machine on RVM. V is the virtualization overhead on normal operations, V/I the overhead on interrupt operations.

ChipnamePlatformBuildYieldMailSemFIFOMsgqBmqVMail/ISem/IMsgq/IBmq/IV/IMemAlrm
STM32L071CBCortex-M0+Keil3827016093021007134714%1370129215451741147%N/A1216
......GCC4007516493211064142019%1424134116031796210%N/A1291
STM32F405RGCortex-M4FKeil25243637220070892440%1180108812881452281%385798
......GCC312540448204656100859%1336125214041572250%380739
STM32F767IGCortex-M7FKeil1842932751445047056%772742899983135%275578
......GCC1923522921484666506%90385310011119239%270508
CH32V307VCRV32IMACGCC23338433614848962917%1287123913401421267%390605
...RV32IMAFC...32549743616961676750%1789174218571951399%390608

Even at the worst case in this table, a virtualized context switch is still around 25× faster than RT-Linux on a comparable Cortex-M7 — and the overhead is bounded, not just small on average.

Metric definitions ​

MetricMeaning
YieldYield from one thread to another
MailMailbox communication between two threads
SemSemaphore communication between two threads
FIFOFIFO read/write pair within a single thread
MsgqMessage queue between two threads (only the receiver may block)
BmqBlocking message queue (both sides may block)
Mail/ISend to a mailbox from an interrupt
Sem/IPost to a semaphore from an interrupt
Msgq/ISend to a message queue from an interrupt
Bmq/ISend to a blocking message queue from an interrupt
MemA pair of memory-pool malloc/free calls
AlrmAverage processing time of five periodic alarms (1/2/3/5/7 ticks)

Reading the numbers ​

  • These are average-case values, chosen for comparability. The per-chip WCETs live in Include/Test/Chip/ and are the numbers to design against.
  • TBD means the port exists and builds, but that measurement has not been taken on hardware yet. N/A means the operation does not apply to that platform (for example, a memory pool that the port does not enable).
  • No "cheating" optimizations are used: no toolchain-specific peephole sequences that break portability, no cooperative switches that avoid the scheduler, no average-case fast paths with unbounded worst cases.
  • Timing values are cycles, not microseconds, so they are independent of the clock frequency. Multiply by the cycle time of the core to get wall-clock numbers.

An official work of EDI, released into the public domain.

GitHub·Discord·QQ 群 1038895132·rtospro.com