Skip to content

Commit

Permalink
benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bfarmer67 committed Dec 16, 2024
1 parent 91beb73 commit 0bff10e
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ namespace Hyperbee.Expressions.Benchmark;

public class AsyncBenchmarks
{
private const int IterationCount = 100;

private Func<Task<int>> _preRunCompiled = null!;
private Func<Task<int>> _preRunFastCompiled = null!;
private Func<Task<int>> _preRunNextCompiled = null!;
//private Func<Task<int>> _preRunNextFastCompiled = null!;

private Func<Task<int>> _coldRunCompiled = null!;
private Func<Task<int>> _coldRunFastCompiled = null!;
private Func<Task<int>> _coldRunNextCompiled = null!;
//private Func<Task<int>> _coldRunNextFastCompiled = null!;

private Expression<Func<Task<int>>> _lambda = null!;
private Expression<Func<Task<int>>> _nextlambda = null!;

Expand All @@ -47,7 +40,7 @@ public void Setup()

_lambda = Lambda<Func<Task<int>>>( _expression );

_nextlambda = CodeGenerator.AsyncLambda<Func<Task<int>>>( ( fun, result ) =>
_nextlambda = CodeGenerator.AsyncLambda<Func<Task<int>>>( ( _, result ) =>
{
var isTrue = CodeGenerator.DeclareVariable( "isTrue", typeof( bool ).New() );

Expand Down Expand Up @@ -93,19 +86,6 @@ void Warmup( params Func<Task<int>>[] funcs )
}
}

[IterationSetup( Targets = [
nameof(Hyperbee_AsyncBlock_FirstExecute),
nameof(Hyperbee_AsyncBlock_FirstFastExecute),
nameof(DotNext_AsyncLambda_FirstExecute)
] )]
public void IterationSetup()
{
_coldRunCompiled = _lambda.Compile();
_coldRunFastCompiled = _lambda.CompileFast();
_coldRunNextCompiled = _nextlambda.Compile();
//_coldRunNextFastCompiled = _nextlambda.CompileFast();
}

// Compile

[BenchmarkCategory( "Compile" )]
Expand All @@ -129,32 +109,6 @@ public void DotNext_AsyncLambda_Compile()
_nextlambda.Compile();
}

// First Execute

[BenchmarkCategory( "First Execute" )]
[Benchmark( Description = "Hyperbee First Execute" )]
[InvocationCount( invocationCount: IterationCount, unrollFactor: 1 )]
public async Task Hyperbee_AsyncBlock_FirstExecute()
{
await _coldRunCompiled();
}

[BenchmarkCategory( "First Execute" )]
[Benchmark( Description = "Hyperbee First Fast Execute" )]
[InvocationCount( invocationCount: IterationCount, unrollFactor: 1 )]
public async Task Hyperbee_AsyncBlock_FirstFastExecute()
{
await _coldRunFastCompiled();
}

[BenchmarkCategory( "First Execute" )]
[Benchmark( Description = "DotNext First Execute" )]
[InvocationCount( invocationCount: IterationCount, unrollFactor: 1 )]
public async Task DotNext_AsyncLambda_FirstExecute()
{
await _coldRunNextCompiled();
}

// Execute

[BenchmarkCategory( "Execute" )]
Expand Down

0 comments on commit 0bff10e

Please sign in to comment.