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 1x
Rust rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball) 0 0 30x
C# 8.0.131 0 0 71x
Java javac 21.0.12.1 0 0 33x
Go go version go1.22.2 linux/amd64 0 0 217x
Pascal 3.2.2 0 0 435x
C++ Ubuntu clang version 18.1.3 (1ubuntu1) 0 0 75x

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

Program ASM Cycles Time SPC Ticks TPC GHz
java/LowLatency n/a 268435456 1.35 .0000000050291419 5255519788 19 3.8
go/fast n/a 268435456 1.58 .0000000058859586 6146465708 22 3.7
cpp/loop 110 268435456 1.86 .0000000069290399 7268262793 27 3.9
cpp/matrixes 161 268435456 1.86 .0000000069290399 7264878011 27 3.9
cpp/binpow-matrix 157 134217728 1.77 .0000000131875276 6898313964 51 3.9
rust/recursion 607 33554432 1.03 .0000000306963920 4035336183 120 3.9
cpp/static_member_functions 71 33554432 1.28 .0000000381469726 4989483766 148 3.9
cpp/inlines 70 33554432 1.37 .0000000408291816 5351086463 159 3.9
cpp/recursion 70 33554432 1.37 .0000000408291816 5351437276 159 3.9
csharp/Recursion n/a 33554432 1.86 .0000000554323196 7321291777 218 3.9
csharp/Functions n/a 33554432 1.89 .0000000563263893 7425011224 221 3.9
go/recursion n/a 33554432 1.99 .0000000593066215 7722530115 230 3.9
java/Functions n/a 16777216 1.03 .0000000613927841 4013195763 239 3.9
java/Recursion n/a 16777216 1.03 .0000000613927841 4007515784 238 3.9
cpp/stack_objects 82 16777216 1.14 .0000000679492950 4462885635 266 3.9
cpp/classes 82 16777216 1.15 .0000000685453414 4462467953 265 3.9
pascal/recursion n/a 16777216 1.56 .0000000929832458 6094560198 363 3.9
cpp/functions 86 8388608 1.22 .0000001454353332 4763241391 567 3.9
cpp/decorators 198 8388608 1.76 .0000002098083496 6790602791 809 3.9
haskell/zipwith 985 4194304 1.25 .0000002980232238 4874706866 1162 3.9
haskell/iterate 906 4194304 1.26 .0000003004074096 4901974440 1168 3.9
haskell/tail_recursion 781 4194304 1.39 .0000003314018249 5451139531 1299 3.9
haskell/object_dynamic 1113 4194304 1.42 .0000003385543823 5553019272 1323 3.9
haskell/recursion 788 4194304 1.60 .0000003814697265 6268245114 1494 3.9
haskell/polymorphic_recursion 2082 4194304 2.00 .0000004768371582 7795209555 1858 3.9
haskell/objects 973 2097152 1.03 .0000004911422729 4044735991 1928 3.9
haskell/adt 920 2097152 1.13 .0000005388259887 4330609718 2064 3.8
rust/structs 708 2097152 1.96 .0000009346008300 7697230790 3670 3.9
cpp/novirtual 210 524288 1.00 .0000019073486328 3912019736 7461 3.9
java/Objects n/a 524288 1.08 .0000020599365234 4226397177 8061 3.9
java/Records n/a 524288 1.09 .0000020790100097 4291357750 8185 3.9
csharp/Structs n/a 262144 1.01 .0000038528442382 3963315497 15118 3.9
csharp/Objects n/a 262144 1.05 .0000040054321289 4128466921 15748 3.9
cpp/interpreter 2945 262144 1.10 .0000041961669921 4284373956 16343 3.9
cpp/functions_with_new 201 262144 1.37 .0000052261352539 5351247602 20413 3.9
cpp/lambdas 449 262144 1.86 .0000070953369140 7262128463 27702 3.9
cpp/objects 518 131072 1.44 .0000109863281250 5646448974 43078 3.9
go/structs n/a 131072 1.63 .0000124359130859 6549952007 49972 4.0
pascal/Objects n/a 32768 1.31 .0000399780273437 5174722272 157919 4.0

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.