Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
FreePhoenix888 committed Jan 11, 2022
1 parent 64b4b66 commit 0784050
Showing 1 changed file with 23 additions and 43 deletions.
66 changes: 23 additions & 43 deletions csharp/Platform.Setters.Benchmarks/LambdaVsSetterBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
using BenchmarkDotNet.Attributes;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using BenchmarkDotNet.Attributes;
namespace Platform.Setters.Benchmarks
{
[SimpleJob]
[MemoryDiagnoser]
public class LambdaVsSetterBenchmarks
{
[GlobalSetup]
public static void Setup()
{

}
namespace Platform.Setters.Benchmarks;

[GlobalCleanup]
public static void Cleanup()
{

}

int Process(Func<IList<int>, int> func)
{
return func(new List<int>{0,1,2,3,4,5,6,7,8,9});
}

[Benchmark]
public int LambdaBenchmark()
{
int result;
var trueValue = 1;
var falseValue = 2;
int Lambda(IList<int> list)
{
result = list[0];
return trueValue;
}
return Process(Lambda);
}
[SimpleJob]
[MemoryDiagnoser]
public class LambdaVsSetterBenchmarks
{
private int Process(Func<IList<int>, int> func) => func(new List<int> { 0, 1, 2, 3 });

[Benchmark]
public int SetterBenchmark()
[Benchmark]
public int LambdaBenchmark()
{
int result;
var trueValue = 1;
var falseValue = 2;
int Lambda(IList<int> list)
{
var setter = new Setter<int, int>(1, 2);
return Process(setter.SetFirstAndReturnTrue);
result = list[0];
return trueValue;
}

return Process(Lambda);
}

[Benchmark]
public int SetterBenchmark()
{
var setter = new Setter<int, int>(1, 2);
return Process(setter.SetFirstAndReturnTrue);
}
}

0 comments on commit 0784050

Please sign in to comment.