Skip to content

Commit e1b28eb

Browse files
committed
Add benchmark for async disposal
1 parent 1a82810 commit e1b28eb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System.Collections.Generic;
5+
using BenchmarkDotNet.Attributes;
6+
using NUnit.Framework;
7+
using osu.Framework.Allocation;
8+
using osu.Framework.Graphics;
9+
using osu.Framework.Graphics.Shapes;
10+
11+
namespace osu.Framework.Benchmarks
12+
{
13+
[MemoryDiagnoser]
14+
public partial class BenchmarkAsyncDisposal
15+
{
16+
private readonly List<Drawable> objects = new List<Drawable>();
17+
18+
[GlobalSetup]
19+
[OneTimeSetUp]
20+
public virtual void SetUp()
21+
{
22+
objects.Clear();
23+
for (int i = 0; i < 10000; i++)
24+
objects.Add(new Box());
25+
}
26+
27+
[Test]
28+
[Benchmark]
29+
public void Run()
30+
{
31+
objects.ForEach(AsyncDisposalQueue.Enqueue);
32+
AsyncDisposalQueue.WaitForEmpty();
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)