Remove old implementation benchmark.
This commit is contained in:
@@ -14,22 +14,13 @@ namespace Avalonia.Benchmarks.Animations
|
||||
[MemoryDiagnoser]
|
||||
public class TransitionBenchmark
|
||||
{
|
||||
private readonly DoubleTransition _transition;
|
||||
private readonly DoubleTransitionOld _oldTransition;
|
||||
private readonly Subject<double> _timeProducer;
|
||||
private readonly List<double> _producedValues;
|
||||
private readonly AddValueObserver _observer;
|
||||
|
||||
[Params(10, 100)]
|
||||
public int FrameCount { get; set; }
|
||||
private readonly List<double> _producedValues;
|
||||
private readonly Subject<double> _timeProducer;
|
||||
private readonly DoubleTransition _transition;
|
||||
|
||||
public TransitionBenchmark()
|
||||
{
|
||||
_oldTransition = new DoubleTransitionOld
|
||||
{
|
||||
Duration = TimeSpan.FromMilliseconds(FrameCount), Property = Layoutable.WidthProperty
|
||||
};
|
||||
|
||||
_transition = new DoubleTransition
|
||||
{
|
||||
Duration = TimeSpan.FromMilliseconds(FrameCount), Property = Layoutable.WidthProperty
|
||||
@@ -41,23 +32,13 @@ namespace Avalonia.Benchmarks.Animations
|
||||
_observer = new AddValueObserver(_producedValues);
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void OldTransition()
|
||||
{
|
||||
TransitionCommon(_oldTransition);
|
||||
}
|
||||
[Params(10, 100)] public int FrameCount { get; set; }
|
||||
|
||||
[Benchmark]
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void NewTransition()
|
||||
{
|
||||
TransitionCommon(_transition);
|
||||
}
|
||||
|
||||
private void TransitionCommon(Transition<double> transition)
|
||||
{
|
||||
var transitionObs = transition.DoTransition(_timeProducer, 0, 1);
|
||||
var transitionObs = _transition.DoTransition(_timeProducer, 0, 1);
|
||||
|
||||
_producedValues.Clear();
|
||||
|
||||
@@ -65,24 +46,12 @@ namespace Avalonia.Benchmarks.Animations
|
||||
|
||||
for (int i = 0; i < FrameCount; i++)
|
||||
{
|
||||
_timeProducer.OnNext(i/1000d);
|
||||
_timeProducer.OnNext(i / 1000d);
|
||||
}
|
||||
|
||||
Debug.Assert(_producedValues.Count == FrameCount);
|
||||
}
|
||||
|
||||
private class DoubleTransitionOld : Transition<double>
|
||||
{
|
||||
private static readonly DoubleAnimator s_animator = new DoubleAnimator();
|
||||
|
||||
/// <inheritdocs/>
|
||||
public override IObservable<double> DoTransition(IObservable<double> progress, double oldValue, double newValue)
|
||||
{
|
||||
return progress
|
||||
.Select(progress => s_animator.Interpolate(Easing.Ease(progress), oldValue, newValue));
|
||||
}
|
||||
}
|
||||
|
||||
private class AddValueObserver : IObserver<double>
|
||||
{
|
||||
private readonly List<double> _values;
|
||||
|
||||
Reference in New Issue
Block a user