2021-09-09 05:47:19 +00: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 06:15:18 +00:00
|
|
|
using BenchmarkDotNet.Engines;
|
2021-09-09 05:47:19 +00:00
|
|
|
using osu.Game.Online.API;
|
2021-09-09 07:46:24 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-09-09 05:47:19 +00:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
|
|
|
|
namespace osu.Game.Benchmarks
|
|
|
|
{
|
|
|
|
public class BenchmarkRuleset : BenchmarkTest
|
|
|
|
{
|
2022-07-09 13:07:47 +00:00
|
|
|
private OsuRuleset ruleset = null!;
|
|
|
|
private APIMod apiModDoubleTime = null!;
|
|
|
|
private APIMod apiModDifficultyAdjust = null!;
|
2021-09-09 05:47:19 +00: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 02:09:13 +00:00
|
|
|
ruleset.CreateAllMods().Consume(new Consumer());
|
2021-09-09 05:47:19 +00:00
|
|
|
}
|
2021-09-09 07:34:49 +00:00
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetAllModsForReference()
|
|
|
|
{
|
2021-09-10 02:09:13 +00:00
|
|
|
ruleset.AllMods.Consume(new Consumer());
|
2021-09-09 07:34:49 +00:00
|
|
|
}
|
2021-09-09 07:46:24 +00:00
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetForAcronym()
|
|
|
|
{
|
2021-09-10 02:09:13 +00:00
|
|
|
ruleset.CreateModFromAcronym("DT");
|
2021-09-09 07:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void BenchmarkGetForType()
|
|
|
|
{
|
2021-09-10 02:09:13 +00:00
|
|
|
ruleset.CreateMod<ModDoubleTime>();
|
2021-09-09 07:46:24 +00:00
|
|
|
}
|
2021-09-09 05:47:19 +00:00
|
|
|
}
|
|
|
|
}
|