Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions osu-framework.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AABB/@EntryIndexedValue">AABB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ARGB/@EntryIndexedValue">ARGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BBH/@EntryIndexedValue">BBH</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BPM/@EntryIndexedValue">BPM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CG/@EntryIndexedValue">CG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FBO/@EntryIndexedValue">FBO</s:String>
Expand Down Expand Up @@ -991,6 +992,7 @@ private void load()
<s:Boolean x:Key="/Default/UserDictionary/Words/=beatmaps/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=beatmap_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bindable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=branchless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Catmull/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Drawables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gameplay/@EntryIndexedValue">True</s:Boolean>
Expand Down
84 changes: 84 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkPathBBHProgressUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics.Lines;
using osuTK;

namespace osu.Framework.Benchmarks
{
public class BenchmarkPathBBHProgressUpdate : BenchmarkTest
{
private readonly PathBBH bbh100 = new PathBBH();
private readonly PathBBH bbh1K = new PathBBH();
private readonly PathBBH bbh10K = new PathBBH();
private readonly PathBBH bbh100K = new PathBBH();
private readonly PathBBH bbh1M = new PathBBH();

private readonly Random random = new Random(1);

public override void SetUp()
{
base.SetUp();

List<Vector2> vertices100 = new List<Vector2>(100);
List<Vector2> vertices1K = new List<Vector2>(1_000);
List<Vector2> vertices10K = new List<Vector2>(10_000);
List<Vector2> vertices100K = new List<Vector2>(100_000);
List<Vector2> vertices1M = new List<Vector2>(1_000_000);

for (int i = 0; i < vertices100.Capacity; i++)
vertices100.Add(new Vector2(random.NextSingle(), random.NextSingle()));

for (int i = 0; i < vertices1K.Capacity; i++)
vertices1K.Add(new Vector2(random.NextSingle(), random.NextSingle()));

for (int i = 0; i < vertices10K.Capacity; i++)
vertices10K.Add(new Vector2(random.NextSingle(), random.NextSingle()));

for (int i = 0; i < vertices100K.Capacity; i++)
vertices100K.Add(new Vector2(random.NextSingle(), random.NextSingle()));

for (int i = 0; i < vertices1M.Capacity; i++)
vertices1M.Add(new Vector2(random.NextSingle(), random.NextSingle()));

bbh100.SetVertices(vertices100, 10);
bbh1K.SetVertices(vertices1K, 10);
bbh10K.SetVertices(vertices10K, 10);
bbh100K.SetVertices(vertices100K, 10);
bbh1M.SetVertices(vertices1M, 10);
}

[Benchmark]
public void SetStartProgressBBH100()
{
bbh100.StartProgress = random.NextSingle();
}

[Benchmark]
public void SetStartProgressBBH1K()
{
bbh1K.StartProgress = random.NextSingle();
}

[Benchmark]
public void SetStartProgressBBH10K()
{
bbh10K.StartProgress = random.NextSingle();
}

[Benchmark]
public void SetStartProgressBBH100K()
{
bbh100K.StartProgress = random.NextSingle();
}

[Benchmark]
public void SetStartProgressBBH1M()
{
bbh1M.StartProgress = random.NextSingle();
}
}
}
85 changes: 85 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkPathReceivePositionalInputAt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics.Lines;
using osuTK;

namespace osu.Framework.Benchmarks
{
public class BenchmarkPathReceivePositionalInputAt : BenchmarkTest
{
// We deliberately set path radius to 0 to introduce worst-case scenario in which with any position given we won't land on a path.
private readonly Path path100 = new Path { PathRadius = 0f };
private readonly Path path1K = new Path { PathRadius = 0f };
private readonly Path path10K = new Path { PathRadius = 0f };
private readonly Path path100K = new Path { PathRadius = 0f };
private readonly Path path1M = new Path { PathRadius = 0f };

private readonly Random random = new Random(1);

public override void SetUp()
{
base.SetUp();

List<Vector2> vertices100 = new List<Vector2>(100);
List<Vector2> vertices1K = new List<Vector2>(1_000);
List<Vector2> vertices10K = new List<Vector2>(10_000);
List<Vector2> vertices100K = new List<Vector2>(100_000);
List<Vector2> vertices1M = new List<Vector2>(1_000_000);

for (int i = 0; i < vertices100.Capacity; i++)
vertices100.Add(new Vector2((float)i / vertices100.Capacity * 100, random.NextSingle() * 100));

for (int i = 0; i < vertices1K.Capacity; i++)
vertices1K.Add(new Vector2((float)i / vertices1K.Capacity * 100, random.NextSingle() * 100));

for (int i = 0; i < vertices10K.Capacity; i++)
vertices10K.Add(new Vector2((float)i / vertices10K.Capacity * 100, random.NextSingle() * 100));

for (int i = 0; i < vertices100K.Capacity; i++)
vertices100K.Add(new Vector2((float)i / vertices100K.Capacity * 100, random.NextSingle() * 100));

for (int i = 0; i < vertices1M.Capacity; i++)
vertices1M.Add(new Vector2((float)i / vertices1M.Capacity * 100, random.NextSingle() * 100));

path100.Vertices = vertices100;
path1K.Vertices = vertices1K;
path10K.Vertices = vertices10K;
path100K.Vertices = vertices100K;
path1M.Vertices = vertices1M;
}

[Benchmark]
public void Contains100()
{
path100.ReceivePositionalInputAt(new Vector2(random.NextSingle() * 100, random.NextSingle() * 100));
}

[Benchmark]
public void Contains1K()
{
path1K.ReceivePositionalInputAt(new Vector2(random.NextSingle() * 100, random.NextSingle() * 100));
}

[Benchmark]
public void Contains10K()
{
path10K.ReceivePositionalInputAt(new Vector2(random.NextSingle() * 100, random.NextSingle() * 100));
}

[Benchmark]
public void Contains100K()
{
path100K.ReceivePositionalInputAt(new Vector2(random.NextSingle() * 100, random.NextSingle() * 100));
}

[Benchmark]
public void Contains1M()
{
path1M.ReceivePositionalInputAt(new Vector2(random.NextSingle() * 100, random.NextSingle() * 100));
}
}
}
87 changes: 87 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkPathSegmentCreation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Primitives;
using osuTK;

namespace osu.Framework.Benchmarks
{
public partial class BenchmarkPathSegmentCreation : BenchmarkTest
{
private readonly List<Vector2> vertices100 = new List<Vector2>(100);
private readonly List<Vector2> vertices1K = new List<Vector2>(1_000);
private readonly List<Vector2> vertices10K = new List<Vector2>(10_000);
private readonly List<Vector2> vertices100K = new List<Vector2>(100_000);
private readonly List<Vector2> vertices1M = new List<Vector2>(1_000_000);

private readonly BenchPath path = new BenchPath();
private readonly Consumer consumer = new Consumer();

public override void SetUp()
{
base.SetUp();

var rng = new Random(1);

for (int i = 0; i < vertices100.Capacity; i++)
vertices100.Add(new Vector2(rng.NextSingle(), rng.NextSingle()));

for (int i = 0; i < vertices1K.Capacity; i++)
vertices1K.Add(new Vector2(rng.NextSingle(), rng.NextSingle()));

for (int i = 0; i < vertices10K.Capacity; i++)
vertices10K.Add(new Vector2(rng.NextSingle(), rng.NextSingle()));

for (int i = 0; i < vertices100K.Capacity; i++)
vertices100K.Add(new Vector2(rng.NextSingle(), rng.NextSingle()));

for (int i = 0; i < vertices1M.Capacity; i++)
vertices1M.Add(new Vector2(rng.NextSingle(), rng.NextSingle()));
}

[Benchmark]
public void Compute100Segments()
{
path.Vertices = vertices100;
consumer.Consume(path.Segments);
}

[Benchmark]
public void Compute1KSegments()
{
path.Vertices = vertices1K;
consumer.Consume(path.Segments);
}

[Benchmark]
public void Compute10KSegments()
{
path.Vertices = vertices10K;
consumer.Consume(path.Segments);
}

[Benchmark]
public void Compute100KSegments()
{
path.Vertices = vertices100K;
consumer.Consume(path.Segments);
}

[Benchmark]
public void Compute1MSegments()
{
path.Vertices = vertices1M;
consumer.Consume(path.Segments);
}

private partial class BenchPath : Path
{
public IEnumerable<Line> Segments => BBH.Segments;
}
}
}
Loading
Loading