-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dd
committed
Oct 18, 2021
1 parent
cd4bdcd
commit 4853cd5
Showing
7 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/MethodBoundaryAspect.Fody.Benchmark/Directory.Build.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" | ||
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<SignAssembly>false</SignAssembly> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Weavers VerifyAssembly="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<MethodBoundaryAspect/> | ||
</Weavers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="MethodBoundaryAspect" minOccurs="0" maxOccurs="1" type="xs:anyType" /> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
17 changes: 17 additions & 0 deletions
17
src/MethodBoundaryAspect.Fody.Benchmark/MethodBoundaryAspect.Fody.Benchmark.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" /> | ||
<PackageReference Include="Fody" Version="6.0.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.140" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Running; | ||
using MethodBoundaryAspect.Fody.Attributes; | ||
|
||
namespace MethodBoundaryAspect.Fody.Benchmark | ||
{ | ||
public class InvocationBenchmark | ||
{ | ||
[Benchmark] | ||
public int MethodCallWithAspect() => TestClass.ExecuteWithAspect(5); | ||
|
||
[Benchmark] | ||
public int MethodCallWithoutAspect() => TestClass.ExecuteWithoutAspect(5); | ||
} | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var summary = BenchmarkRunner.Run<InvocationBenchmark>(); | ||
} | ||
} | ||
|
||
|
||
class TestClass | ||
{ | ||
[TestAspect] | ||
public static int ExecuteWithAspect(int x) | ||
{ | ||
var sum = 0; | ||
for (var i = 0; i < 100; i++) | ||
sum += i * x; | ||
|
||
return sum; | ||
} | ||
|
||
public static int ExecuteWithoutAspect(int x) | ||
{ | ||
var sum = 0; | ||
for (var i = 0; i < 100; i++) | ||
sum += i * x; | ||
|
||
return sum; | ||
} | ||
} | ||
|
||
class TestAspect : OnMethodBoundaryAspect | ||
{ | ||
public override void OnEntry(MethodExecutionArgs arg) | ||
{ | ||
base.OnEntry(arg); | ||
} | ||
|
||
public override void OnExit(MethodExecutionArgs arg) | ||
{ | ||
base.OnEntry(arg); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters