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.
43 lines
1.1 KiB
43 lines
1.1 KiB
using System;
|
|
using System.Reactive.Subjects;
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
namespace Avalonia.Benchmarks.Base
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class AvaloniaObjectBenchmark
|
|
{
|
|
private Class1 target = new Class1();
|
|
private Subject<int> intBinding = new Subject<int>();
|
|
|
|
public AvaloniaObjectBenchmark()
|
|
{
|
|
target.SetValue(Class1.IntProperty, 123);
|
|
}
|
|
|
|
[Benchmark]
|
|
public void ClearAndSetIntProperty()
|
|
{
|
|
target.ClearValue(Class1.IntProperty);
|
|
target.SetValue(Class1.IntProperty, 123);
|
|
}
|
|
|
|
[Benchmark]
|
|
public void BindIntProperty()
|
|
{
|
|
using (target.Bind(Class1.IntProperty, intBinding))
|
|
{
|
|
for (var i = 0; i < 100; ++i)
|
|
{
|
|
intBinding.OnNext(i);
|
|
}
|
|
}
|
|
}
|
|
|
|
class Class1 : AvaloniaObject
|
|
{
|
|
public static readonly AvaloniaProperty<int> IntProperty =
|
|
AvaloniaProperty.Register<Class1, int>("Int");
|
|
}
|
|
}
|
|
}
|
|
|