2020-01-08 22:06:18 +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 System.IO;
|
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
|
using osu.Framework.IO.Stores;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
|
|
|
|
using osu.Game.IO;
|
|
|
|
|
using osu.Game.IO.Archives;
|
2022-02-16 16:21:06 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2020-05-23 22:18:55 +08:00
|
|
|
|
using osu.Game.Tests.Resources;
|
2020-01-08 22:06:18 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Benchmarks
|
|
|
|
|
{
|
|
|
|
|
public class BenchmarkBeatmapParsing : BenchmarkTest
|
|
|
|
|
{
|
|
|
|
|
private readonly MemoryStream beatmapStream = new MemoryStream();
|
|
|
|
|
|
|
|
|
|
public override void SetUp()
|
|
|
|
|
{
|
2022-02-16 16:21:06 +08:00
|
|
|
|
Decoder.RegisterDependencies(new AssemblyRulesetStore());
|
|
|
|
|
|
2020-05-23 22:18:55 +08:00
|
|
|
|
using (var resources = new DllResourceStore(typeof(TestResources).Assembly))
|
2020-05-23 23:01:34 +08:00
|
|
|
|
using (var archive = resources.GetStream("Resources/Archives/241526 Soleily - Renatus.osz"))
|
2020-01-08 22:06:18 +08:00
|
|
|
|
using (var reader = new ZipArchiveReader(archive))
|
|
|
|
|
reader.GetStream("Soleily - Renatus (Gamu) [Insane].osu").CopyTo(beatmapStream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
|
public Beatmap BenchmarkBundledBeatmap()
|
|
|
|
|
{
|
|
|
|
|
beatmapStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
var reader = new LineBufferedReader(beatmapStream); // no disposal
|
|
|
|
|
|
|
|
|
|
var decoder = Decoder.GetDecoder<Beatmap>(reader);
|
|
|
|
|
return decoder.Decode(reader);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|