-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCopyAndRemove.cs
More file actions
39 lines (32 loc) · 819 Bytes
/
CopyAndRemove.cs
File metadata and controls
39 lines (32 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
namespace HashSetPerf
{
public abstract class CopyAndRemove<T>
{
private FastHashSet<T> _hashSet;
private T[] _found;
protected abstract T[] GetItems();
[Params(512)]
public int Size;
[GlobalSetup]
public void SetUp()
{
_found = GetItems();
_hashSet = new FastHashSet<T>(_found);
}
[Benchmark]
public bool Remove()
{
var res = false;
var found = _found;
var copy = new FastHashSet<T>(_hashSet);
for (var i = 0; i < found.Length; i++)
{
res ^= copy.Remove(found[i]);
}
return res;
}
}
}