Skip to content

Commit e76955d

Browse files
committed
Add direct access benchmarking
1 parent d4afc72 commit e76955d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Benchmarking/BenchmarkTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,36 @@ public void IterateDictList()
109109
}
110110
}
111111

112+
[Benchmark]
113+
public void AccessList()
114+
{
115+
// access all indexes of multiples of 5
116+
for (var i = 0; i < N; i += 5)
117+
{
118+
_ = _iterList[i];
119+
}
120+
}
121+
122+
[Benchmark]
123+
public void AccessDict()
124+
{
125+
// access all indexes of multiples of 5
126+
for (var i = 0; i < N; i += 5)
127+
{
128+
_ = _iterDict[i];
129+
}
130+
}
131+
132+
[Benchmark]
133+
public void AccessDictList()
134+
{
135+
// access all indexes of multiples of 5
136+
for (var i = 0; i < N; i += 5)
137+
{
138+
_ = _iterDictList[i];
139+
}
140+
}
141+
112142
[Benchmark]
113143
public void RemoveManyFromListThenTrim()
114144
{

0 commit comments

Comments
 (0)