2021-09-09 13:47:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using BenchmarkDotNet.Attributes;
|
2021-09-09 14:15:18 +08:00
|
|
|
using BenchmarkDotNet.Engines;
|
2021-09-09 13:47:19 +08:00
|
|
|
using osu.Game.Online.API;
|
2021-09-09 15:46:24 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-09-09 13:47:19 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
|
|
|
|
namespace osu.Game.Benchmarks
|
|
|
|
{
|
|
|
|
public class BenchmarkRuleset : BenchmarkTest
|
|
|
|
{
|
2022-07-09 21:07:47 +08:00
|
|
|
private OsuRuleset ruleset = null!;
|
|
|
|
private APIMod apiModDoubleTime = null!;
|
|
|
|
private APIMod apiModDifficultyAdjust = null!;
|
2021-09-09 13:47:19 +08:00
|
|
|
|
|
|
|
public override void SetUp()
|
|
|
|
{
|
|
|
|
base.SetUp();
|
|
|
|
ruleset = new OsuRuleset();
|
|
|
|
apiModDoubleTime = new APIMod { Acronym = "DT" };
|
|
|
|
apiModDifficultyAdjust = new APIMod { Acronym = "DA" };
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkToModDoubleTime()
|
|
|
|
{
|
|
|
|
apiModDoubleTime.ToMod(ruleset);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkToModDifficultyAdjust()
|
|
|
|
{
|
|
|
|
apiModDifficultyAdjust.ToMod(ruleset);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetAllMods()
|
|
|
|
{
|
2021-09-10 10:09:13 +08:00
|
|
|
ruleset.CreateAllMods().Consume(new Consumer());
|
2021-09-09 13:47:19 +08:00
|
|
|
}
|
2021-09-09 15:34:49 +08:00
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetAllModsForReference()
|
|
|
|
{
|
2021-09-10 10:09:13 +08:00
|
|
|
ruleset.AllMods.Consume(new Consumer());
|
2021-09-09 15:34:49 +08:00
|
|
|
}
|
2021-09-09 15:46:24 +08:00
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetForAcronym()
|
|
|
|
{
|
2021-09-10 10:09:13 +08:00
|
|
|
ruleset.CreateModFromAcronym("DT");
|
2021-09-09 15:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetForType()
|
|
|
|
{
|
2021-09-10 10:09:13 +08:00
|
|
|
ruleset.CreateMod<ModDoubleTime>();
|
2021-09-09 15:46:24 +08:00
|
|
|
}
|
2021-09-09 13:47:19 +08:00
|
|
|
}
|
|
|
|
}
|