Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections benchmarks rewrite #92

Merged
merged 32 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
13e43b2
ctor default size all collections benchmarks
adamsitnik Jul 11, 2018
85f98c1
ctor given size all collections benchmarks
adamsitnik Jul 11, 2018
34fc804
ctor from collection all collections benchmarks
adamsitnik Jul 11, 2018
af04aa7
move to a dedicated folder, add categories
adamsitnik Jul 11, 2018
8fb685d
iterate for each all collections
adamsitnik Jul 11, 2018
3321633
iterate for loop all collections
adamsitnik Jul 11, 2018
cf7fa2f
iterate for each non generic collections
adamsitnik Jul 11, 2018
578c546
iterate for loop non generic collections
adamsitnik Jul 11, 2018
cfafed8
update to BDN which offers glob filtering so I can filter like a pro ;)
adamsitnik Jul 11, 2018
1f81328
Contains for all generic collections
adamsitnik Jul 12, 2018
aff1094
ContainsKey for all generic collections
adamsitnik Jul 12, 2018
6e68408
add benchmarks
adamsitnik Jul 12, 2018
a954576
try add benchmarks
adamsitnik Jul 12, 2018
c9a467b
Enqueue and Push benchmarks
adamsitnik Jul 12, 2018
8317a31
Indexer Set benchmarks
adamsitnik Jul 12, 2018
fb4a0fe
remove benchmarks
adamsitnik Jul 12, 2018
512d24b
clear benchmarks
adamsitnik Jul 12, 2018
eb1344f
refactoring and cleanup + set LangVersion to latest
adamsitnik Jul 13, 2018
6ccfc27
add missing benchmarks
adamsitnik Jul 13, 2018
6bbd707
Merge remote-tracking branch 'upstream/master' into collectionsRewrite
adamsitnik Jul 13, 2018
41aa067
fix a typo
adamsitnik Jul 17, 2018
255f153
add missing ConcurrentBag.TryTake benchmark
adamsitnik Jul 17, 2018
843741c
AddRemoveFromSameThreads benchmarks
adamsitnik Jul 17, 2018
baf6e76
AddRemoveFromDifferentThreads benchmarks
adamsitnik Jul 17, 2018
a99efaf
IsEmpty benchmarks
adamsitnik Jul 17, 2018
e279cfb
Count benchmarks
adamsitnik Jul 17, 2018
90fa210
support new glob filters
adamsitnik Jul 17, 2018
87527d1
add ICollection, IDictionary and IEnumerable benchmarks
adamsitnik Jul 19, 2018
229c5e6
use more future proof constant
adamsitnik Jul 19, 2018
d734b8e
code review fixes
adamsitnik Jul 19, 2018
71d8e8e
NETFRAMEWORK is predefined const!
adamsitnik Jul 19, 2018
fb87ea3
remove the array benchmark
adamsitnik Jul 19, 2018
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
Prev Previous commit
Next Next commit
ctor given size all collections benchmarks
  • Loading branch information
adamsitnik committed Jul 11, 2018
commit 85f98c1dcd55aacc685c22ee18a80dd28f8455df
43 changes: 43 additions & 0 deletions src/benchmarks/corefx/System.Collections/CtorGivenSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using Benchmarks;

namespace System.Collections
{
[BenchmarkCategory(Categories.CoreFX, Categories.Collections)]
[GenericTypeArguments(typeof(int), typeof(int))] // value type
[GenericTypeArguments(typeof(string), typeof(string))] // reference type
public class CtorGiventSize<TKey, TValue>
{
private const int ConcurrencyLevel = 4;

[Params(100)]
public int Size;

[Benchmark]
public TKey[] Array() => new TKey[Size];

[Benchmark]
public List<TKey> List() => new List<TKey>(Size);

#if !NET461 // API added in .NET Core 2.0
[Benchmark]
public HashSet<TKey> HashSet() => new HashSet<TKey>(Size);
#endif
[Benchmark]
public Dictionary<TKey, TValue> Dictionary() => new Dictionary<TKey, TValue>(Size);

[Benchmark]
public Queue<TKey> Queue() => new Queue<TKey>(Size);

[Benchmark]
public Stack<TKey> Stack() => new Stack<TKey>(Size);

[Benchmark]
public SortedList<TKey, TValue> SortedList() => new SortedList<TKey, TValue>(Size);

[Benchmark]
public ConcurrentDictionary<TKey, TValue> ConcurrentDictionary() => new ConcurrentDictionary<TKey, TValue>(ConcurrencyLevel, Size);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BenchmarkDotNet.Attributes;

namespace System.Collections
{
public class CtorGivenSizeNonGeneric
{
[Params(100)]
public int Size;

[Benchmark]
public ArrayList ArrayList() => new ArrayList(Size);

[Benchmark]
public Hashtable Hashtable() => new Hashtable(Size);

[Benchmark]
public Queue Queue() => new Queue(Size);

[Benchmark]
public Stack Stack() => new Stack(Size);

[Benchmark]
public SortedList SortedList() => new SortedList(Size);
}
}