Skip to content

Commit 5ce68c7

Browse files
committed
fix bs fibo
1 parent 58cb62e commit 5ce68c7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

samples/bench/bootsharp/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

samples/bench/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
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

1313
All 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` |

0 commit comments

Comments
 (0)