Skip to content

Commit

Permalink
Merge pull request #353 from microsoft/ujjwalchadha/benchmarks
Browse files Browse the repository at this point in the history
Added Reflection Performance Benchmarks
  • Loading branch information
manodasanW authored Aug 4, 2020
2 parents 7e2f90a + 5d8ee53 commit 86ac082
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Benchmarks/Benchmarks.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
name="BenchmarkComponent.ClassWithMultipleInterfaces"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="BenchmarkComponent.ClassWithMarshalingRoutines"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>

</assembly>
65 changes: 65 additions & 0 deletions Benchmarks/ReflectionPerf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using BenchmarkComponent;
using BenchmarkDotNet.Attributes;

namespace Benchmarks
{
[MemoryDiagnoser]
public class ReflectionPerf
{
ClassWithMarshalingRoutines instance;

[GlobalSetup]
public void Setup()
{
instance = new ClassWithMarshalingRoutines();
}

[Benchmark]
public object ExecuteMarshalingForNewKeyValuePair()
{
return instance.NewTypeErasedKeyValuePairObject;
}

[Benchmark]
public object ExecuteMarshalingForNewArray()
{
return instance.NewTypeErasedArrayObject;
}

[Benchmark]
public object ExecuteMarshalingForNewNullable()
{
return instance.NewTypeErasedNullableObject;
}

[Benchmark]
public object ExecuteMarshalingForExistingKeyvaluePair()
{
return instance.ExistingTypeErasedKeyValuePairObject;
}

[Benchmark]
public object ExecuteMarshalingForExistingArray()
{
return instance.ExistingTypeErasedArrayObject;
}

[Benchmark]
public object ExecuteMarshalingForExistingNullable()
{
return instance.ExistingTypeErasedNullableObject;
}

[Benchmark]
public object ExecuteMarshalingForString()
{
return instance.DefaultStringProperty;
}

[Benchmark]
public object ExecuteMarshalingForCustomObject()
{
return instance.NewWrappedClassObject;
}
}
}

0 comments on commit 86ac082

Please sign in to comment.