mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Move ReadOnlyDictionary allocation to global setup
This commit is contained in:
@@ -12,10 +12,13 @@ namespace osu.Framework.Benchmarks
|
||||
public class BenchmarkSlimReadOnlyDictionary
|
||||
{
|
||||
private readonly Dictionary<int, int> dictionary = new Dictionary<int, int>();
|
||||
private ReadOnlyDictionary<int, int> readOnlyDictionary = null!;
|
||||
|
||||
[GlobalSetup]
|
||||
public void GlobalSetup()
|
||||
{
|
||||
readOnlyDictionary = new ReadOnlyDictionary<int, int>(dictionary);
|
||||
|
||||
int[] values = { 0, 1, 2, 3, 4, 5, 3, 2, 3, 1, 4, 5, -1 };
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
dictionary[i] = values[i];
|
||||
@@ -40,8 +43,6 @@ namespace osu.Framework.Benchmarks
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
ReadOnlyDictionary<int, int> readOnlyDictionary = new ReadOnlyDictionary<int, int>(dictionary);
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
foreach ((_, int v) in readOnlyDictionary)
|
||||
@@ -84,8 +85,6 @@ namespace osu.Framework.Benchmarks
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
ReadOnlyDictionary<int, int> readOnlyDictionary = new ReadOnlyDictionary<int, int>(dictionary);
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
foreach (int v in readOnlyDictionary.Keys)
|
||||
@@ -128,8 +127,6 @@ namespace osu.Framework.Benchmarks
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
ReadOnlyDictionary<int, int> readOnlyDictionary = new ReadOnlyDictionary<int, int>(dictionary);
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
foreach (int v in readOnlyDictionary.Values)
|
||||
|
||||
Reference in New Issue
Block a user