Skip to content

Performance Benchmarks

Sergei Fedorov edited this page Nov 21, 2016 · 2 revisions

Simple benchmark results. Definition of state machines is almost the same, the difference is due to differences in libraries (afsm vs boost::msm).

Benchmarks execute same tasks with afsm and boost::msm libraries, the names of benchmark are prefixed by AFSM and MSM respectively. The construction with parameters benchmarks may be biased by the fact that msm library doesn't support rvalue parameters.

Benchmarks are built with google benchmark suite.

Interpreting the tables: less Time and CPU and more Iterations is faster.

Test of November 20, 2016

Test machine: Mac OS X 10.11.6, CPU 2.9GHz Intel Core i7 (4 cores) RAM 8Gb.

Compiler: Apple LLVM version 8.0.0 (clang-800.0.42.1)

CMAKE_BUILD_TYPE=Debug

Benchmark Time CPU Iterations
AFSM_ConstructDefault 952 ns 945 ns 736493
MSM_ConstructDefault 3904 ns 3874 ns 179265
AFSM_ConstructWithData 1679 ns 1671 ns 399035
MSM_ConstructWithData 5266 ns 5230 ns 121964
AFSM_ProcessSingleEvent 1152 ns 1147 ns 618577
MSM_ProcessSingleEvent 1506 ns 1488 ns 467206
AFSM_OnOffEmpty 1188 ns 1183 ns 564320
MSM_OnOffEmpty 3897 ns 3853 ns 184825
AFSM_OnOffLoaded 1286 ns 1279 ns 519084
MSM_OnOffLoaded 2830 ns 2805 ns 251702
AFSM_BuyItem 4056 ns 4039 ns 176494
MSM_BuyItem 5531 ns 5480 ns 128210

CMAKE_BUILD_TYPE=RelWithDebInfo

Benchmark Time CPU Iterations
AFSM_ConstructDefault 27 ns 26 ns 27064855
MSM_ConstructDefault 42 ns 42 ns 16044705
AFSM_ConstructWithData 258 ns 254 ns 2893088
MSM_ConstructWithData 513 ns 512 ns 1311353
AFSM_ProcessSingleEvent 94 ns 94 ns 7605637
MSM_ProcessSingleEvent 328 ns 327 ns 2158662
AFSM_OnOffEmpty 103 ns 103 ns 6600722
MSM_OnOffEmpty 648 ns 646 ns 1074823
AFSM_OnOffLoaded 111 ns 110 ns 6269873
MSM_OnOffLoaded 349 ns 349 ns 2112455
AFSM_BuyItem 286 ns 286 ns 2423470
MSM_BuyItem 1049 ns 1042 ns 640158

Test of November 21, 2016

Test machine: Ubuntu 15.04 Linux 4.2.0-42-generic, CPU Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (8 cores) RAM 16 Gb

Compiler: g++ 5.2.1

CMAKE_BUILD_TYPE=Debug

Benchmark Time CPU Iterations
AFSM_ConstructDefault 1614 ns 1610 ns 411099
MSM_ConstructDefault 6120 ns 6070 ns 103530
AFSM_ConstructWithData 2223 ns 2219 ns 320484
MSM_ConstructWithData 7357 ns 7329 ns 97078
AFSM_ProcessSingleEvent 1609 ns 1609 ns 470538
MSM_ProcessSingleEvent 1422 ns 1422 ns 504705
AFSM_OnOffEmpty 1844 ns 1844 ns 373343
MSM_OnOffEmpty 3834 ns 3828 ns 184115
AFSM_OnOffLoaded 2024 ns 2024 ns 347939
MSM_OnOffLoaded 2806 ns 2802 ns 250836
AFSM_BuyItem 5475 ns 5475 ns 128285
MSM_BuyItem 5287 ns 5288 ns 129182

CMAKE_BUILD_TYPE=RelWithDebInfo

Benchmark Time CPU Iterations
AFSM_ConstructDefault 221 ns 221 ns 2860570
MSM_ConstructDefault 474 ns 474 ns 1338322
AFSM_ConstructWithData 369 ns 368 ns 2036676
MSM_ConstructWithData 666 ns 666 ns 1067758
AFSM_ProcessSingleEvent 197 ns 196 ns 3689882
MSM_ProcessSingleEvent 143 ns 143 ns 4902505
AFSM_OnOffEmpty 230 ns 230 ns 3044086
MSM_OnOffEmpty 276 ns 276 ns 2577299
AFSM_OnOffLoaded 239 ns 239 ns 2984187
MSM_OnOffLoaded 141 ns 141 ns 5125447
AFSM_BuyItem 540 ns 540 ns 1246353
MSM_BuyItem 448 ns 448 ns 1588010
Clone this wiki locally