Created
November 25, 2019 21:26
-
-
Save bdach/0edda878ee2664faf2bbd0056fdfe9ca to your computer and use it in GitHub Desktop.
Easing curve benchmark (ppy/osu-framework#3026)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using BenchmarkDotNet.Attributes; | |
using osu.Framework.Graphics; | |
using osu.Framework.MathUtils; | |
namespace osu.Framework.Tests | |
{ | |
public class EasingBenchmark | |
{ | |
[Params(Easing.InExpo, Easing.InElastic, Easing.OutElasticHalf, Easing.OutElasticQuarter, Easing.InOutElastic)] | |
public Easing Easing { get; set; } | |
private double[] args; | |
[GlobalSetup] | |
public void Setup() | |
{ | |
args = Enumerable.Range(1, 1000) | |
.Select(arg => arg / 1000.0) | |
.ToArray(); | |
} | |
[Benchmark] | |
public double[] ApplyEasing() => args.Select(arg => Interpolation.ApplyEasing(Easing, arg)).ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment