Skip to content

Instantly share code, notes, and snippets.

@bdach
Created November 25, 2019 21:26
Show Gist options
  • Save bdach/0edda878ee2664faf2bbd0056fdfe9ca to your computer and use it in GitHub Desktop.
Save bdach/0edda878ee2664faf2bbd0056fdfe9ca to your computer and use it in GitHub Desktop.
Easing curve benchmark (ppy/osu-framework#3026)
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