Skip to content

Commit b262565

Browse files
committed
Call benchmark method directly instead of via delegate.
1 parent bed071f commit b262565

File tree

6 files changed

+202
-214
lines changed

6 files changed

+202
-214
lines changed

src/BenchmarkDotNet/Code/CodeGenerator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ internal static string Generate(BuildPartition buildPartition)
4545
.Replace("$ID$", buildInfo.Id.ToString())
4646
.Replace("$OperationsPerInvoke$", provider.OperationsPerInvoke)
4747
.Replace("$WorkloadTypeName$", provider.WorkloadTypeName)
48-
.Replace("$WorkloadMethodDelegate$", provider.WorkloadMethodDelegate(passArguments))
4948
.Replace("$WorkloadMethodReturnType$", provider.WorkloadMethodReturnTypeName)
5049
.Replace("$WorkloadMethodReturnTypeModifiers$", provider.WorkloadMethodReturnTypeModifiers)
5150
.Replace("$OverheadMethodReturnTypeName$", provider.OverheadMethodReturnTypeName)

src/BenchmarkDotNet/Code/DeclarationsProvider.cs

-8
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ internal abstract class DeclarationsProvider
3636

3737
public virtual string WorkloadMethodReturnTypeName => WorkloadMethodReturnType.GetCorrectCSharpTypeName();
3838

39-
public virtual string WorkloadMethodDelegate(string passArguments) => Descriptor.WorkloadMethod.Name;
40-
4139
public virtual string WorkloadMethodReturnTypeModifiers => null;
4240

4341
public virtual string GetWorkloadMethodCall(string passArguments) => $"{Descriptor.WorkloadMethod.Name}({passArguments})";
@@ -151,9 +149,6 @@ public TaskDeclarationsProvider(Descriptor descriptor) : base(descriptor) { }
151149

152150
// we use GetAwaiter().GetResult() because it's fastest way to obtain the result in blocking way,
153151
// and will eventually throw actual exception, not aggregated one
154-
public override string WorkloadMethodDelegate(string passArguments)
155-
=> $"({passArguments}) => {{ {Descriptor.WorkloadMethod.Name}({passArguments}).GetAwaiter().GetResult(); }}";
156-
157152
public override string GetWorkloadMethodCall(string passArguments) => $"{Descriptor.WorkloadMethod.Name}({passArguments}).GetAwaiter().GetResult()";
158153

159154
protected override Type WorkloadMethodReturnType => typeof(void);
@@ -170,9 +165,6 @@ public GenericTaskDeclarationsProvider(Descriptor descriptor) : base(descriptor)
170165

171166
// we use GetAwaiter().GetResult() because it's fastest way to obtain the result in blocking way,
172167
// and will eventually throw actual exception, not aggregated one
173-
public override string WorkloadMethodDelegate(string passArguments)
174-
=> $"({passArguments}) => {{ return {Descriptor.WorkloadMethod.Name}({passArguments}).GetAwaiter().GetResult(); }}";
175-
176168
public override string GetWorkloadMethodCall(string passArguments) => $"{Descriptor.WorkloadMethod.Name}({passArguments}).GetAwaiter().GetResult()";
177169
}
178170
}

src/BenchmarkDotNet/Helpers/Reflection.Emit/ModuleBuilderExtensions.cs

-60
This file was deleted.

0 commit comments

Comments
 (0)