Skip to content

Commit d54daec

Browse files
committed
Add Fibonacci
1 parent 8ee4da8 commit d54daec

File tree

8 files changed

+42
-26
lines changed

8 files changed

+42
-26
lines changed

fibonacci/csharp/code.cs

-5
This file was deleted.

fibonacci/csharp/in-process/code.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var runMs = int.Parse(args[0]);
2+
var warmupMs = int.Parse(args[1]);
3+
var n = int.Parse(args[2]);
4+
5+
Benchmark<int>.Run(() => Fibonacci(n), warmupMs);
6+
7+
var result = Benchmark<int>.Run(() => Fibonacci(n), runMs);
8+
9+
Console.WriteLine(result);
10+
11+
return;
12+
13+
static int Fibonacci(int n) =>
14+
n <= 1 ? n : Fibonacci(n - 1) + Fibonacci(n - 2);
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Compile Include="..\..\..\lib\csharp\benchmark.cs">
12+
<Link>benchmark.cs</Link>
13+
</Compile>
14+
</ItemGroup>
15+
16+
</Project>

fibonacci/csharp/legacy/code.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static int Fibonacci(int n) =>
2+
n <= 1 ? n : Fibonacci(n - 1) + Fibonacci(n - 2);
3+
4+
var u = int.Parse(args[0]);
5+
var r = 0;
6+
for (var i = 1; i < u; i++)
7+
{
8+
r += Fibonacci(i);
9+
}
10+
Console.WriteLine(r);

loops/csharp/code.csproj fibonacci/csharp/legacy/code.csproj

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,4 @@
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

10-
<ItemGroup>
11-
<Compile Include="..\..\lib\csharp\Benchmark.cs">
12-
<Link>Benchmark.cs</Link>
13-
</Compile>
14-
</ItemGroup>
15-
16-
</Project>
10+
</Project>

fibonacci/csharp/run.cs

-8
This file was deleted.

hello-world/csharp/legacy/code.cs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Console.WriteLine("Hello, World!");

fibonacci/csharp/code.csproj hello-world/csharp/legacy/code.csproj

-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,4 @@
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

10-
<ItemGroup>
11-
<Compile Include="..\..\lib\csharp\Benchmark.cs">
12-
<Link>Benchmark.cs</Link>
13-
</Compile>
14-
</ItemGroup>
15-
1610
</Project>

0 commit comments

Comments
 (0)