From a21880d4a8e8b51e51af6098a1b32d9727056576 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 30 May 2021 12:31:53 +0200 Subject: [PATCH] Remove old implementation benchmark. --- .../Animations/TransitionBenchmark.cs | 43 +++---------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/tests/Avalonia.Benchmarks/Animations/TransitionBenchmark.cs b/tests/Avalonia.Benchmarks/Animations/TransitionBenchmark.cs index aba59d4585..f74457a924 100644 --- a/tests/Avalonia.Benchmarks/Animations/TransitionBenchmark.cs +++ b/tests/Avalonia.Benchmarks/Animations/TransitionBenchmark.cs @@ -14,22 +14,13 @@ namespace Avalonia.Benchmarks.Animations [MemoryDiagnoser] public class TransitionBenchmark { - private readonly DoubleTransition _transition; - private readonly DoubleTransitionOld _oldTransition; - private readonly Subject _timeProducer; - private readonly List _producedValues; private readonly AddValueObserver _observer; - - [Params(10, 100)] - public int FrameCount { get; set; } + private readonly List _producedValues; + private readonly Subject _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 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 - { - private static readonly DoubleAnimator s_animator = new DoubleAnimator(); - - /// - public override IObservable DoTransition(IObservable progress, double oldValue, double newValue) - { - return progress - .Select(progress => s_animator.Interpolate(Easing.Ease(progress), oldValue, newValue)); - } - } - private class AddValueObserver : IObserver { private readonly List _values;