This repo contains benchmarks for C++ state machine libraries.
It has been originally created to test various optimizations of the Boost MSM library.
The benchmarks are inspired by the fsm-benchmark repository.
Header inclusion:
No instantiation of a state machine, only the headers of the library are included.
Large state machine:
Same benchmark as tested in fsm-benchmark.
Large hierarchical state machine:
This benchmarks is an extension of the large state machine and consists of a hierarchical structure of 3 state machines:
-
fsm0 is the root state machine
-
fsm1 is contained in fsm0
-
fsm2 is contained in fsm1
The events handled by each state machine overlap with each other to simulate transition conflicts.
The following libraries are benchmarked:
MSM:
MSM is used with 3 back-ends back, back11 and backmp11.
The back-end backmp11 is a recent addition. For more details about the applied optimizations and changes to previous back-ends take a look at the backmp11’s README.
Only the functor frontend is used in the benchmarks. The following backend configurations are tested:
-
backbackend withfavor_runtime_speedandfavor_compile_timecompile policies -
back11backend -
backmp11backend withfavor_runtime_speedandfavor_compile_timecompile policies
Last run was done on commit 158beca9aa0a08f83e005e536fd9bae21637d51b.
SML:
SML is tested with a default configuration.
Last run was done on commit 0bdc4f593a3a1cc5bb45e0464c0923683d099d86.
The benchmark results will be updated every once in a while in case one of the libraries has performance-relevant updates for the benchmarks.
Following results are from a benchmark run from 2025-11-22 with the following HW & SW:
-
Intel i7-6700K @4GHZ, 32 GB RAM
-
Clang 19.1.4, RelWithDebInfo, C++20
-
CUs are compiled one-by-one except the multi_cu benchmark for MSM with
backmp11&favor_compile_time
Header inclusion
| Compile / sec | RAM / MB | |
|---|---|---|
back |
2.3 |
223 |
back_favor_compile_time |
2.3 |
223 |
back11 |
2.3 |
223 |
backmp11 |
0.9 |
148 |
backmp11_favor_compile_time |
1.2 |
152 |
sml |
0.1 |
94 |
Large state machine
| Compile / sec | RAM / MB | Runtime / sec | |
|---|---|---|---|
back |
18 |
953 |
7 |
back_favor_compile_time |
21 |
1000 |
8 |
back11 |
43 |
2794 |
7 |
backmp11 |
3 |
239 |
3 |
backmp11_favor_compile_time |
3 |
220 |
13 |
sml |
12 |
363 |
3 |
Large hierarchical state machine
| Compile / sec | RAM / MB | Runtime / sec | |
|---|---|---|---|
back |
68 |
2849 |
23 |
back_favor_compile_time |
80 |
2551 |
261 |
backmp11 |
11 |
472 |
10 |
backmp11_favor_compile_time |
6 |
288 |
40 |
backmp11_favor_compile_time_multi_cu |
5 |
~925 |
40 |
sml |
48 |
1128 |
11 |