csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
using System;
|
|
using Avalonia.Data.Core.Plugins;
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
namespace Avalonia.Benchmarks.Data
|
|
{
|
|
[MemoryDiagnoser, InProcess]
|
|
public class PropertyAccessorBenchmarks
|
|
{
|
|
private readonly InpcPropertyAccessorPlugin _inpcPlugin = new InpcPropertyAccessorPlugin();
|
|
private readonly ReflectionMethodAccessorPlugin _methodPlugin = new ReflectionMethodAccessorPlugin();
|
|
private readonly AccessorTestObject _targetStrongRef = new AccessorTestObject();
|
|
private readonly WeakReference<object> _targetWeakRef;
|
|
|
|
public PropertyAccessorBenchmarks()
|
|
{
|
|
_targetWeakRef = new WeakReference<object>(_targetStrongRef);
|
|
}
|
|
|
|
[Benchmark]
|
|
public void InpcAccessorMatch()
|
|
{
|
|
_inpcPlugin.Match(_targetWeakRef, nameof(AccessorTestObject.Test));
|
|
}
|
|
|
|
[Benchmark]
|
|
public void InpcAccessorStart()
|
|
{
|
|
_inpcPlugin.Start(_targetWeakRef, nameof(AccessorTestObject.Test));
|
|
}
|
|
|
|
[Benchmark]
|
|
public void MethodAccessorMatch()
|
|
{
|
|
_methodPlugin.Match(_targetWeakRef, nameof(AccessorTestObject.Execute));
|
|
}
|
|
|
|
[Benchmark]
|
|
public void MethodAccessorStart()
|
|
{
|
|
_methodPlugin.Start(_targetWeakRef, nameof(AccessorTestObject.Execute));
|
|
}
|
|
}
|
|
}
|
|
|