From 1ca53c6670cb4f7f1bb12862494138a9311cff6e Mon Sep 17 00:00:00 2001 From: Brenton Farmer Date: Sat, 14 Dec 2024 07:15:29 -0800 Subject: [PATCH] compiler-services renam --- .../AsyncBlockExpression.cs | 2 +- src/Hyperbee.Expressions/AwaitExpression.cs | 2 +- .../AwaitBinder.cs | 7 ++++++- .../AwaitBinderFactory.cs | 2 +- .../JumpTableBuilder.cs | 2 +- .../LoweringException.cs | 2 +- .../LoweringVisitor.cs | 6 +++--- .../ReflectionHelper.cs | 2 +- .../StateContext.cs | 4 ++-- .../StateMachineBuilder.cs | 2 +- .../StateMachineContext.cs | 2 +- .../StateNode.cs | 4 ++-- .../StateOptimizer.cs | 4 ++-- .../StateResult.cs | 2 +- .../Transitions/AwaitTransition.cs | 2 +- .../Transitions/ConditionalTransition.cs | 2 +- .../Transitions/FinalTransition.cs | 2 +- .../Transitions/GotoTransition.cs | 2 +- .../Transitions/LoopTransition.cs | 2 +- .../Transitions/SwitchTransition.cs | 2 +- .../Transitions/Transition.cs | 2 +- .../Transitions/TryCatchTransition.cs | 2 +- .../VariableResolver.cs | 2 +- .../AsyncBenchmarks.cs | 19 ++++++++++++++----- .../BlockAsyncBasicTests.cs | 14 ++++++++------ .../Compiler/CompilerTests2.cs | 2 +- 26 files changed, 56 insertions(+), 40 deletions(-) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/AwaitBinder.cs (98%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/AwaitBinderFactory.cs (99%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/JumpTableBuilder.cs (97%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/LoweringException.cs (69%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/LoweringVisitor.cs (98%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/ReflectionHelper.cs (99%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateContext.cs (98%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateMachineBuilder.cs (99%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateMachineContext.cs (94%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateNode.cs (93%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateOptimizer.cs (95%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/StateResult.cs (86%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/AwaitTransition.cs (98%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/ConditionalTransition.cs (95%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/FinalTransition.cs (94%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/GotoTransition.cs (91%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/LoopTransition.cs (90%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/SwitchTransition.cs (97%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/Transition.cs (96%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/Transitions/TryCatchTransition.cs (98%) rename src/Hyperbee.Expressions/{Transformation => CompilerServices}/VariableResolver.cs (99%) diff --git a/src/Hyperbee.Expressions/AsyncBlockExpression.cs b/src/Hyperbee.Expressions/AsyncBlockExpression.cs index c513196..37cd4b7 100644 --- a/src/Hyperbee.Expressions/AsyncBlockExpression.cs +++ b/src/Hyperbee.Expressions/AsyncBlockExpression.cs @@ -1,7 +1,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq.Expressions; -using Hyperbee.Expressions.Transformation; +using Hyperbee.Expressions.CompilerServices; namespace Hyperbee.Expressions; diff --git a/src/Hyperbee.Expressions/AwaitExpression.cs b/src/Hyperbee.Expressions/AwaitExpression.cs index 519c29f..c647098 100644 --- a/src/Hyperbee.Expressions/AwaitExpression.cs +++ b/src/Hyperbee.Expressions/AwaitExpression.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using System.Linq.Expressions; -using Hyperbee.Expressions.Transformation; +using Hyperbee.Expressions.CompilerServices; namespace Hyperbee.Expressions; diff --git a/src/Hyperbee.Expressions/Transformation/AwaitBinder.cs b/src/Hyperbee.Expressions/CompilerServices/AwaitBinder.cs similarity index 98% rename from src/Hyperbee.Expressions/Transformation/AwaitBinder.cs rename to src/Hyperbee.Expressions/CompilerServices/AwaitBinder.cs index 76d2f71..dec5273 100644 --- a/src/Hyperbee.Expressions/Transformation/AwaitBinder.cs +++ b/src/Hyperbee.Expressions/CompilerServices/AwaitBinder.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal delegate TAwaiter AwaitBinderGetAwaiterDelegate( ref TAwaitable awaitable, bool configureAwait ); internal delegate TResult AwaitBinderGetResultDelegate( ref TAwaiter awaiter ); @@ -155,4 +155,9 @@ internal TResult GetResult( ref TAwaiter awaiter ) return result; } + + public override string ToString() + { + return ".Binder"; + } } diff --git a/src/Hyperbee.Expressions/Transformation/AwaitBinderFactory.cs b/src/Hyperbee.Expressions/CompilerServices/AwaitBinderFactory.cs similarity index 99% rename from src/Hyperbee.Expressions/Transformation/AwaitBinderFactory.cs rename to src/Hyperbee.Expressions/CompilerServices/AwaitBinderFactory.cs index 4defc58..198355a 100644 --- a/src/Hyperbee.Expressions/Transformation/AwaitBinderFactory.cs +++ b/src/Hyperbee.Expressions/CompilerServices/AwaitBinderFactory.cs @@ -3,7 +3,7 @@ using System.Reflection.Emit; using System.Runtime.CompilerServices; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal static class AwaitBinderFactory { diff --git a/src/Hyperbee.Expressions/Transformation/JumpTableBuilder.cs b/src/Hyperbee.Expressions/CompilerServices/JumpTableBuilder.cs similarity index 97% rename from src/Hyperbee.Expressions/Transformation/JumpTableBuilder.cs rename to src/Hyperbee.Expressions/CompilerServices/JumpTableBuilder.cs index 15e6a62..ea895ab 100644 --- a/src/Hyperbee.Expressions/Transformation/JumpTableBuilder.cs +++ b/src/Hyperbee.Expressions/CompilerServices/JumpTableBuilder.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal static class JumpTableBuilder { diff --git a/src/Hyperbee.Expressions/Transformation/LoweringException.cs b/src/Hyperbee.Expressions/CompilerServices/LoweringException.cs similarity index 69% rename from src/Hyperbee.Expressions/Transformation/LoweringException.cs rename to src/Hyperbee.Expressions/CompilerServices/LoweringException.cs index 2342859..aac88fb 100644 --- a/src/Hyperbee.Expressions/Transformation/LoweringException.cs +++ b/src/Hyperbee.Expressions/CompilerServices/LoweringException.cs @@ -1,4 +1,4 @@ -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal class LoweringException : Exception { diff --git a/src/Hyperbee.Expressions/Transformation/LoweringVisitor.cs b/src/Hyperbee.Expressions/CompilerServices/LoweringVisitor.cs similarity index 98% rename from src/Hyperbee.Expressions/Transformation/LoweringVisitor.cs rename to src/Hyperbee.Expressions/CompilerServices/LoweringVisitor.cs index e02529d..0a49b8f 100644 --- a/src/Hyperbee.Expressions/Transformation/LoweringVisitor.cs +++ b/src/Hyperbee.Expressions/CompilerServices/LoweringVisitor.cs @@ -1,9 +1,9 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; -using Hyperbee.Expressions.Transformation.Transitions; +using Hyperbee.Expressions.CompilerServices.Transitions; using Hyperbee.Expressions.Visitors; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal class LoweringVisitor : ExpressionVisitor { @@ -418,7 +418,7 @@ protected Expression VisitAwaitExtension( AwaitExpression node ) sourceState.StateId ); - var resumeLabel = Expression.Label( $"{joinState.NodeLabel.Name}_RESUME" ); + var resumeLabel = Expression.Label( $"{sourceState.NodeLabel.Name}_RESUME" ); var awaitTransition = new AwaitTransition { diff --git a/src/Hyperbee.Expressions/Transformation/ReflectionHelper.cs b/src/Hyperbee.Expressions/CompilerServices/ReflectionHelper.cs similarity index 99% rename from src/Hyperbee.Expressions/Transformation/ReflectionHelper.cs rename to src/Hyperbee.Expressions/CompilerServices/ReflectionHelper.cs index 3739be3..a1dd759 100644 --- a/src/Hyperbee.Expressions/Transformation/ReflectionHelper.cs +++ b/src/Hyperbee.Expressions/CompilerServices/ReflectionHelper.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; public delegate bool MethodMatchDelegate( Type[] parameterTypes, int? argCount = null ); diff --git a/src/Hyperbee.Expressions/Transformation/StateContext.cs b/src/Hyperbee.Expressions/CompilerServices/StateContext.cs similarity index 98% rename from src/Hyperbee.Expressions/Transformation/StateContext.cs rename to src/Hyperbee.Expressions/CompilerServices/StateContext.cs index 58f7a51..e9606aa 100644 --- a/src/Hyperbee.Expressions/Transformation/StateContext.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateContext.cs @@ -1,8 +1,8 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; -using Hyperbee.Expressions.Transformation.Transitions; +using Hyperbee.Expressions.CompilerServices.Transitions; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal sealed class StateContext { diff --git a/src/Hyperbee.Expressions/Transformation/StateMachineBuilder.cs b/src/Hyperbee.Expressions/CompilerServices/StateMachineBuilder.cs similarity index 99% rename from src/Hyperbee.Expressions/Transformation/StateMachineBuilder.cs rename to src/Hyperbee.Expressions/CompilerServices/StateMachineBuilder.cs index 8f1e2dc..ea9117f 100644 --- a/src/Hyperbee.Expressions/Transformation/StateMachineBuilder.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateMachineBuilder.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; public interface IVoidResult; // Marker interface for void Task results public delegate void MoveNextDelegate( T stateMachine ) where T : IAsyncStateMachine; diff --git a/src/Hyperbee.Expressions/Transformation/StateMachineContext.cs b/src/Hyperbee.Expressions/CompilerServices/StateMachineContext.cs similarity index 94% rename from src/Hyperbee.Expressions/Transformation/StateMachineContext.cs rename to src/Hyperbee.Expressions/CompilerServices/StateMachineContext.cs index cf87c4d..5df8b95 100644 --- a/src/Hyperbee.Expressions/Transformation/StateMachineContext.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateMachineContext.cs @@ -1,7 +1,7 @@  using System.Linq.Expressions; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal sealed class StateMachineContext { diff --git a/src/Hyperbee.Expressions/Transformation/StateNode.cs b/src/Hyperbee.Expressions/CompilerServices/StateNode.cs similarity index 93% rename from src/Hyperbee.Expressions/Transformation/StateNode.cs rename to src/Hyperbee.Expressions/CompilerServices/StateNode.cs index 8e5adb1..2d77f01 100644 --- a/src/Hyperbee.Expressions/Transformation/StateNode.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateNode.cs @@ -1,9 +1,9 @@ using System.Diagnostics; using System.Linq.Expressions; -using Hyperbee.Expressions.Transformation.Transitions; +using Hyperbee.Expressions.CompilerServices.Transitions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; [DebuggerDisplay( "State = {NodeLabel?.Name,nq}, ScopeId = {ScopeId}, GroupId = {GroupId}, StateOrder = {StateOrder}, Transition = {Transition?.GetType().Name,nq}" )] internal sealed class StateNode diff --git a/src/Hyperbee.Expressions/Transformation/StateOptimizer.cs b/src/Hyperbee.Expressions/CompilerServices/StateOptimizer.cs similarity index 95% rename from src/Hyperbee.Expressions/Transformation/StateOptimizer.cs rename to src/Hyperbee.Expressions/CompilerServices/StateOptimizer.cs index 91adb7a..039448c 100644 --- a/src/Hyperbee.Expressions/Transformation/StateOptimizer.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateOptimizer.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; -using Hyperbee.Expressions.Transformation.Transitions; +using Hyperbee.Expressions.CompilerServices.Transitions; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal sealed class StateOptimizer { diff --git a/src/Hyperbee.Expressions/Transformation/StateResult.cs b/src/Hyperbee.Expressions/CompilerServices/StateResult.cs similarity index 86% rename from src/Hyperbee.Expressions/Transformation/StateResult.cs rename to src/Hyperbee.Expressions/CompilerServices/StateResult.cs index 1f320a6..ba8a65f 100644 --- a/src/Hyperbee.Expressions/Transformation/StateResult.cs +++ b/src/Hyperbee.Expressions/CompilerServices/StateResult.cs @@ -1,6 +1,6 @@ using System.Linq.Expressions; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal sealed class StateResult { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/AwaitTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/AwaitTransition.cs similarity index 98% rename from src/Hyperbee.Expressions/Transformation/Transitions/AwaitTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/AwaitTransition.cs index d6afe71..0e867c9 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/AwaitTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/AwaitTransition.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class AwaitTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/ConditionalTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/ConditionalTransition.cs similarity index 95% rename from src/Hyperbee.Expressions/Transformation/Transitions/ConditionalTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/ConditionalTransition.cs index d5f3a26..ae0d8cc 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/ConditionalTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/ConditionalTransition.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class ConditionalTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/FinalTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/FinalTransition.cs similarity index 94% rename from src/Hyperbee.Expressions/Transformation/Transitions/FinalTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/FinalTransition.cs index 00b7848..881c1a0 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/FinalTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/FinalTransition.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class FinalTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/GotoTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/GotoTransition.cs similarity index 91% rename from src/Hyperbee.Expressions/Transformation/Transitions/GotoTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/GotoTransition.cs index 31134f0..0ddfa5a 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/GotoTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/GotoTransition.cs @@ -1,6 +1,6 @@ using System.Linq.Expressions; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class GotoTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/LoopTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/LoopTransition.cs similarity index 90% rename from src/Hyperbee.Expressions/Transformation/Transitions/LoopTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/LoopTransition.cs index 9c01bbb..9c275be 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/LoopTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/LoopTransition.cs @@ -1,6 +1,6 @@ using System.Linq.Expressions; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class LoopTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/SwitchTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/SwitchTransition.cs similarity index 97% rename from src/Hyperbee.Expressions/Transformation/Transitions/SwitchTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/SwitchTransition.cs index 5a3f996..961024e 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/SwitchTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/SwitchTransition.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class SwitchTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/Transition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/Transition.cs similarity index 96% rename from src/Hyperbee.Expressions/Transformation/Transitions/Transition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/Transition.cs index f446327..174c8d9 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/Transition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/Transition.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; [DebuggerDisplay( "Transition = {GetType().Name,nq}" )] diff --git a/src/Hyperbee.Expressions/Transformation/Transitions/TryCatchTransition.cs b/src/Hyperbee.Expressions/CompilerServices/Transitions/TryCatchTransition.cs similarity index 98% rename from src/Hyperbee.Expressions/Transformation/Transitions/TryCatchTransition.cs rename to src/Hyperbee.Expressions/CompilerServices/Transitions/TryCatchTransition.cs index b1dfca1..7fad9a8 100644 --- a/src/Hyperbee.Expressions/Transformation/Transitions/TryCatchTransition.cs +++ b/src/Hyperbee.Expressions/CompilerServices/Transitions/TryCatchTransition.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation.Transitions; +namespace Hyperbee.Expressions.CompilerServices.Transitions; internal class TryCatchTransition : Transition { diff --git a/src/Hyperbee.Expressions/Transformation/VariableResolver.cs b/src/Hyperbee.Expressions/CompilerServices/VariableResolver.cs similarity index 99% rename from src/Hyperbee.Expressions/Transformation/VariableResolver.cs rename to src/Hyperbee.Expressions/CompilerServices/VariableResolver.cs index e2eea5f..3478575 100644 --- a/src/Hyperbee.Expressions/Transformation/VariableResolver.cs +++ b/src/Hyperbee.Expressions/CompilerServices/VariableResolver.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using static System.Linq.Expressions.Expression; -namespace Hyperbee.Expressions.Transformation; +namespace Hyperbee.Expressions.CompilerServices; internal sealed class VariableResolver : ExpressionVisitor { diff --git a/test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs b/test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs index 17cbcdf..7508a4d 100644 --- a/test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs +++ b/test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs @@ -75,14 +75,10 @@ public void Setup() _preRunFastCompiled = _lambda.CompileFast(); _preRunNextCompiled = _nextlambda.Compile(); - _coldRunCompiled = _lambda.Compile(); - _coldRunFastCompiled = _lambda.CompileFast(); - _coldRunNextCompiled = _nextlambda.Compile(); - //_preRunFastNextCompiled = _nextlambda.CompileFast(); - //_coldRunNextFastCompiled = _nextlambda.CompileFast(); Warmup( _preRunCompiled, _preRunFastCompiled, _preRunNextCompiled ); + return; // Helpers @@ -96,6 +92,19 @@ void Warmup( params Func>[] 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" )] diff --git a/test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs b/test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs index b8d79bd..18998cb 100644 --- a/test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs +++ b/test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs @@ -87,13 +87,13 @@ public async Task BlockAsync_ShouldAwaitMultipleTasks_WithDifferentResults( Comp // Arrange var block = BlockAsync( Await( AsyncHelper.Completer( - Constant( completer ), - Constant( 1 ) - ) ), + Constant( completer ), + Constant( 1 ) + ) ), Await( AsyncHelper.Completer( - Constant( completer ), - Constant( 2 ) - ) ) + Constant( completer ), + Constant( 2 ) + ) ) ); var lambda = Lambda>>( block ); @@ -114,6 +114,7 @@ public async Task BlockAsync_ShouldThrowException_WithFaultedTask() var block = BlockAsync( Await( Constant( Task.FromException( new InvalidOperationException( "Test Exception" ) ) ) ) ); + var lambda = Lambda>>( block ); var compiledLambda = lambda.Compile(); @@ -153,6 +154,7 @@ public async Task BlockAsync_ShouldAwaitNestedBlockAsync_WithNestedTasks( Comple Await( AsyncHelper.Completer( Constant( completer ), Constant( 1 ) ) ), Await( innerBlock ) ); + var lambda = Lambda>>( block ); var compiledLambda = lambda.Compile( compiler ); diff --git a/test/Hyperbee.Expressions.Tests/Compiler/CompilerTests2.cs b/test/Hyperbee.Expressions.Tests/Compiler/CompilerTests2.cs index 0bb7338..543d808 100644 --- a/test/Hyperbee.Expressions.Tests/Compiler/CompilerTests2.cs +++ b/test/Hyperbee.Expressions.Tests/Compiler/CompilerTests2.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; using Hyperbee.Expressions.Tests.TestSupport; -using Hyperbee.Expressions.Transformation; +using Hyperbee.Expressions.CompilerServices; using static System.Linq.Expressions.Expression; using static Hyperbee.Expressions.ExpressionExtensions;