1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-23 02:25:12 +08:00

Add test and optimize the performance

This commit is contained in:
normalid 2024-07-03 23:09:21 +08:00
parent 2748b969a0
commit 7f8799169b
2 changed files with 61 additions and 7 deletions

View File

@ -388,37 +388,92 @@ namespace osu.Game.Tests.Rulesets.Scoring
[Test]
public void TestNormalGrades()
{
scoreProcessor.ApplyBeatmap(new Beatmap());
const int count_judgements = 200;
beatmap = new TestBeatmap(new RulesetInfo())
{
HitObjects = new List<HitObject>(Enumerable.Repeat(new TestHitObject(HitResult.Great), count_judgements))
};
scoreProcessor.ApplyBeatmap(beatmap);
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.X));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
scoreProcessor.Accuracy.Value = 0.99f;
// beatmap.HitObjects.Count -100 for simulating the situation of playing in progress
for (int i = 0; i < beatmap.HitObjects.Count - 100; i++)
{
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[i], beatmap.HitObjects[i].Judgement)
{
Type = i == beatmap.HitObjects.Count - 101 ? HitResult.Ok : HitResult.Perfect
});
}
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.S));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.S));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
}
[Test]
public void TestSilverGrades()
{
scoreProcessor.ApplyBeatmap(new Beatmap());
const int count_judgements = 200;
beatmap = new TestBeatmap(new RulesetInfo())
{
HitObjects = new List<HitObject>(Enumerable.Repeat(new TestHitObject(HitResult.Great), count_judgements))
};
scoreProcessor.ApplyBeatmap(beatmap);
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.X));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.XH));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
scoreProcessor.Accuracy.Value = 0.99f;
// beatmap.HitObjects.Count -100 for simulating the situation of playing in progress
for (int i = 0; i < beatmap.HitObjects.Count - 100; i++)
{
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[i], beatmap.HitObjects[i].Judgement)
{
Type = i == beatmap.HitObjects.Count - 101 ? HitResult.Ok : HitResult.Perfect
});
}
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.SH));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
}
[Test]
public void TestSilverGradesModsAppliedFirst()
{
const int count_judgements = 200;
beatmap = new TestBeatmap(new RulesetInfo())
{
HitObjects = new List<HitObject>(Enumerable.Repeat(new TestHitObject(HitResult.Great), count_judgements))
};
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
scoreProcessor.ApplyBeatmap(new Beatmap());
scoreProcessor.ApplyBeatmap(beatmap);
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.XH));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
scoreProcessor.Accuracy.Value = 0.99f;
// beatmap.HitObjects.Count -100 for simulating the situation of playing in progress
for (int i = 0; i < beatmap.HitObjects.Count - 100; i++)
{
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[i], beatmap.HitObjects[i].Judgement)
{
Type = i == beatmap.HitObjects.Count - 101 ? HitResult.Ok : HitResult.Perfect
});
}
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
Assert.That(scoreProcessor.MaximumRank.Value, Is.EqualTo(ScoreRank.SH));
Assert.That(scoreProcessor.MinimumRank.Value, Is.EqualTo(ScoreRank.D));
}
private class TestJudgement : Judgement

View File

@ -204,7 +204,6 @@ namespace osu.Game.Rulesets.Scoring
public ScoreProcessor(Ruleset ruleset)
{
Ruleset = ruleset;
Accuracy.ValueChanged += _ => updateRank();
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);