This is how much functions are faster than objects:

TPC
Language Compiler w/functions w/objects Ratio
Haskell The Glorious Glasgow Haskell Compilation System, version 9.4.7 0 0 2x
Rust rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball) 0 0 78x
C# 8.0.131 0 1 104x
Java javac 21.0.12.1 0 1 57x
Go go version go1.22.2 linux/amd64 0 5 296x
Pascal 3.2.2 0 12 450x
C++ Ubuntu clang version 18.1.3 (1ubuntu1) 0 3 76x

This is what it takes to calculate the 16th Fibonacci number using different algorithms:

Program ASM Cycles Time SPC Ticks TPC GHz
cpp/loop 110 536870912 1.38 .0000000025704503 5384671649 10 3.9
go/fast n/a 268435456 1.97 .0000000073388218 7674795670 28 3.8
java/LowLatency n/a 268435456 1.97 .0000000073388218 7654077932 28 3.8
cpp/matrixes 161 134217728 1.03 .0000000076740980 4016900011 29 3.8
cpp/binpow-matrix 157 134217728 1.74 .0000000129640102 6806668114 50 3.9
haskell/zipwith 985 4194304 1.30 .0000003099441528 5109486425 1218 3.9
haskell/iterate 906 4194304 1.33 .0000003170967102 5123867693 1221 3.9
haskell/object_dynamic 1113 4194304 1.74 .0000004148483276 6733786189 1605 3.9
haskell/tail_recursion 781 4194304 1.76 .0000004196166992 6866391097 1637 3.9
rust/recursion 607 524288 1.31 .0000024986267089 5136377000 9796 3.9
cpp/static_member_functions 71 524288 1.62 .0000030899047851 6310194848 12035 3.9
cpp/inlines 70 524288 1.81 .0000034523010253 7016793897 13383 3.9
cpp/recursion 70 524288 1.81 .0000034523010253 7018719703 13387 3.9
csharp/Functions n/a 262144 1.11 .0000042343139648 4324752543 16497 3.9
csharp/Recursion n/a 262144 1.14 .0000043487548828 4464179494 17029 3.9
go/recursion n/a 262144 1.21 .0000046157836914 4698167757 17922 3.9
java/Functions n/a 262144 1.27 .0000048446655273 4944445821 18861 3.9
java/Recursion n/a 262144 1.27 .0000048446655273 4948535551 18877 3.9
cpp/decorators 198 262144 1.28 .0000048828125000 4981048652 19001 3.9
cpp/classes 82 262144 1.42 .0000054168701171 5552358377 21180 3.9
cpp/stack_objects 82 262144 1.42 .0000054168701171 5547295302 21161 3.9
haskell/recursion 788 262144 1.77 .0000067520141601 6909717391 26358 3.9
pascal/recursion n/a 262144 1.93 .0000073623657226 7534697656 28742 3.9
cpp/interpreter 2945 131072 1.18 .0000090026855468 4409109870 33638 3.7
cpp/functions 86 131072 1.49 .0000113677978515 5826953756 44456 3.9
haskell/polymorphic_recursion 2082 131072 1.82 .0000138854980468 7034403192 53668 3.9
haskell/objects 973 65536 1.07 .0000163269042968 4201147939 64104 3.9
haskell/adt 920 65536 1.28 .0000195312500000 5012485930 76484 3.9
cpp/novirtual 210 8192 1.27 .0001550292968750 4955648465 604937 3.9
rust/structs 708 8192 1.64 .0002001953125000 6323643515 771929 3.9
java/Objects n/a 4096 1.13 .0002758789062500 4444032892 1084968 3.9
java/Records n/a 4096 1.13 .0002758789062500 4445122785 1085235 3.9
cpp/functions_with_new 201 4096 1.68 .0004101562500000 6599233458 1611140 3.9
csharp/Objects n/a 4096 1.82 .0004443359375000 7087760660 1730410 3.9
csharp/Structs n/a 4096 1.88 .0004589843750000 7359108305 1796657 3.9
cpp/lambdas 449 2048 1.13 .0005517578125000 4420954068 2158668 3.9
cpp/objects 518 2048 1.75 .0008544921875000 6956116128 3396541 4.0
go/structs n/a 1024 1.39 .0013574218750000 5435733483 5308333 3.9
pascal/Objects n/a 512 1.69 .0033007812500000 6624716509 12938899 3.9

Program: File name as it's seen in the source code repository. ASM: Total number of Assembly instructions seen in the compiled .asm file; not every compiler provides this information though. Cycles: How many times the Fibonacci number has been calculated. Time: How many seconds it took to execute all calculations. SPC: How many seconds per each calculation. Ticks: How many total CPU ticks it took to execute all calculations, according to perf. TPC: How many ticks per a single calculation. GHz: TPC divided by SPC and divided by one billion; this is approximately how fast is the CPU; this metric for all programs is expected to have almost the same values, otherwise something is wrong with the method.

Maximum optimization is enabled in all compilers.

If you want to add another program to the list, just submit a pull request to yegor256/fibonacci.

Here is index.xml with the data. This is TeX summary.tex.

Built on 2026-10-05 by @yegor256 at "Linux ip-172-31-22-158 6.8.0-1016-aws #17-Ubuntu SMP Mon Sep 2 13:48:07 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux" machine.