File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -36,5 +36,8 @@ public class Export (IImport import) : IExport
3636{
3737 public int EchoNumber ( ) => import . GetNumber ( ) ;
3838 public Data EchoStruct ( ) => import . GetStruct ( ) ;
39- public int Fi ( int n ) => n <= 1 ? n : Fi ( n - 1 ) + Fi ( n - 2 ) ;
39+ public int Fi ( int n ) => F ( n ) ;
40+ // Due to heavy recursion, a significant degradation accumulates due to constant
41+ // dereferencing of the instance on each iteration, hence using the static version.
42+ private static int F ( int n ) => n <= 1 ? n : F ( n - 1 ) + F ( n - 2 ) ;
4043}
Original file line number Diff line number Diff line change 66
77## Benches
88
9+ - ` Fibonacci ` — compute with heavy recursion
910- ` Echo Number ` — interop with raw numbers
1011- ` Echo Struct ` — interop with JSON-serialized structs
11- - ` Fibonacci ` — compute performance
1212
1313All results are relative to the Rust baseline (lower is better).
1414
1515## 2024 (.NET 9)
1616
1717| | Rust | Zig | .NET LLVM | Bootsharp | .NET AOT | Go |
1818| -------------| -------| -------| -----------| -----------| ----------| ---------|
19- | Fibonacci | ` 1.0 ` | ` 1.0 ` | ` 1.0 ` | ` 1.5 ` | ` 1.7 ` | ` 3.8 ` |
19+ | Fibonacci | ` 1.0 ` | ` 1.0 ` | ` 1.0 ` | ` 1.0 ` | ` 1.7 ` | ` 3.8 ` |
2020| Echo Number | ` 1.0 ` | ` 0.9 ` | ` 1.6 ` | ` 14.0 ` | ` 23.5 ` | ` 718.7 ` |
2121| Echo Struct | ` 1.0 ` | ` 1.1 ` | ` 2.0 ` | ` 2.5 ` | ` 5.9 ` | ` 15.2 ` |
You can’t perform that action at this time.
0 commit comments