Skip to content

Commit b46e3ef

Browse files
author
Oren (electricessence)
committed
Updated tests and report to output to txt and csv.
1 parent f22ab43 commit b46e3ef

6 files changed

Lines changed: 545 additions & 184 deletions

File tree

benchmarking/BenchmarkResult.csv

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Batch,Pool Type,Take From Empty (In Parallel),Give To (In Parallel),Mixed Read/Write (In Parallel),Empty Pool (.TryTake()),TOTAL,
2+
Repeat 100000 for size 4,LinkedListObjectPool,00:00:00.5446936,00:00:00.9886553,00:00:00.4383719,00:00:00.0944285,00:00:02.0661493,
3+
Repeat 100000 for size 4,QueueObjectPool,00:00:00.5101651,00:00:00.7820358,00:00:00.4396512,00:00:00.0861555,00:00:01.8180076,
4+
Repeat 100000 for size 4,OptimisticArrayObjectPool,00:00:00.4878969,00:00:00.7048874,00:00:00.4294658,00:00:00.0125716,00:00:01.6348217,
5+
Repeat 100000 for size 4,InterlockedArrayObjectPool,00:00:00.5181038,00:00:00.7404542,00:00:00.4350744,00:00:00.0125102,00:00:01.7061426,
6+
Repeat 40000 for size 10,LinkedListObjectPool,00:00:00.3156256,00:00:00.9093478,00:00:00.2870968,00:00:00.0910514,00:00:01.6031216,
7+
Repeat 40000 for size 10,QueueObjectPool,00:00:00.3046181,00:00:00.5989796,00:00:00.2916924,00:00:00.0818583,00:00:01.2771484,
8+
Repeat 40000 for size 10,OptimisticArrayObjectPool,00:00:00.2974992,00:00:00.4454928,00:00:00.2784509,00:00:00.0055634,00:00:01.0270063,
9+
Repeat 40000 for size 10,InterlockedArrayObjectPool,00:00:00.3093777,00:00:00.4456445,00:00:00.2606044,00:00:00.0054850,00:00:01.0211116,
10+
Repeat 8000 for size 100,LinkedListObjectPool,00:00:00.5553015,00:00:01.9316093,00:00:00.3668134,00:00:00.1489426,00:00:03.0026668,
11+
Repeat 8000 for size 100,QueueObjectPool,00:00:00.1716840,00:00:01.0170214,00:00:00.2434091,00:00:00.1359503,00:00:01.5680648,
12+
Repeat 8000 for size 100,OptimisticArrayObjectPool,00:00:00.1624457,00:00:00.8488803,00:00:00.1241455,00:00:00.0012911,00:00:01.1367626,
13+
Repeat 8000 for size 100,InterlockedArrayObjectPool,00:00:00.1695044,00:00:00.8771345,00:00:00.1562285,00:00:00.0012742,00:00:01.2041416,
14+
Repeat 6400 for size 250,LinkedListObjectPool,00:00:00.6692530,00:00:02.7319705,00:00:00.7335461,00:00:00.2487210,00:00:04.3834906,
15+
Repeat 6400 for size 250,QueueObjectPool,00:00:00.2190198,00:00:01.5061960,00:00:00.5232603,00:00:00.2279745,00:00:02.4764506,
16+
Repeat 6400 for size 250,OptimisticArrayObjectPool,00:00:00.2007165,00:00:01.5293083,00:00:00.1518310,00:00:00.0010455,00:00:01.8829013,
17+
Repeat 6400 for size 250,InterlockedArrayObjectPool,00:00:00.2396147,00:00:01.1445379,00:00:00.1543305,00:00:00.0010398,00:00:01.5395229,
18+
Repeat 2400 for size 1000,LinkedListObjectPool,00:00:00.6898274,00:00:02.7620878,00:00:00.7002608,00:00:00.3406904,00:00:04.4928664,
19+
Repeat 2400 for size 1000,QueueObjectPool,00:00:00.2654685,00:00:01.4643862,00:00:00.6240877,00:00:00.3147795,00:00:02.6687219,
20+
Repeat 2400 for size 1000,OptimisticArrayObjectPool,00:00:00.2447782,00:00:00.9322246,00:00:00.2032299,00:00:00.0004221,00:00:01.3806548,
21+
Repeat 2400 for size 1000,InterlockedArrayObjectPool,00:00:00.2853462,00:00:01.2585180,00:00:00.1559039,00:00:00.0004293,00:00:01.7001974,
22+
Repeat 1600 for size 2000,LinkedListObjectPool,00:00:00.8748769,00:00:03.8644551,00:00:00.7567420,00:00:00.4499334,00:00:05.9460074,
23+
Repeat 1600 for size 2000,QueueObjectPool,00:00:00.2797688,00:00:01.5554051,00:00:00.6034681,00:00:00.4108724,00:00:02.8495144,
24+
Repeat 1600 for size 2000,OptimisticArrayObjectPool,00:00:00.2842929,00:00:00.9583302,00:00:00.2346078,00:00:00.0002284,00:00:01.4774593,
25+
Repeat 1600 for size 2000,InterlockedArrayObjectPool,00:00:00.3133074,00:00:00.8566891,00:00:00.2569553,00:00:00.0002253,00:00:01.4271771,
26+
Repeat 1200 for size 4000,LinkedListObjectPool,00:00:01.1456541,00:00:04.5720859,00:00:01.2698255,00:00:00.6735988,00:00:07.6611643,
27+
Repeat 1200 for size 4000,QueueObjectPool,00:00:00.4444606,00:00:02.3798676,00:00:00.7691414,00:00:00.6140109,00:00:04.2074805,
28+
Repeat 1200 for size 4000,OptimisticArrayObjectPool,00:00:00.4147611,00:00:01.3839442,00:00:00.3031743,00:00:00.0001707,00:00:02.1020503,
29+
Repeat 1200 for size 4000,InterlockedArrayObjectPool,00:00:00.3761099,00:00:01.4896086,00:00:00.3215933,00:00:00.0001772,00:00:02.1874890,

benchmarking/BenchmarkResult.txt

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
Repeat 100000 for size 4
2+
------------------------------------
3+
4+
LinkedListObjectPool....................................
5+
00:00:00.5446936 Take From Empty (In Parallel)
6+
00:00:00.9886553 Give To (In Parallel)
7+
00:00:00.4383719 Mixed Read/Write (In Parallel)
8+
00:00:00.0944285 Empty Pool (.TryTake())
9+
00:00:02.0661493 TOTAL
10+
11+
QueueObjectPool.........................................
12+
00:00:00.5101651 Take From Empty (In Parallel)
13+
00:00:00.7820358 Give To (In Parallel)
14+
00:00:00.4396512 Mixed Read/Write (In Parallel)
15+
00:00:00.0861555 Empty Pool (.TryTake())
16+
00:00:01.8180076 TOTAL
17+
18+
OptimisticArrayObjectPool...............................
19+
00:00:00.4878969 Take From Empty (In Parallel)
20+
00:00:00.7048874 Give To (In Parallel)
21+
00:00:00.4294658 Mixed Read/Write (In Parallel)
22+
00:00:00.0125716 Empty Pool (.TryTake())
23+
00:00:01.6348217 TOTAL
24+
25+
InterlockedArrayObjectPool..............................
26+
00:00:00.5181038 Take From Empty (In Parallel)
27+
00:00:00.7404542 Give To (In Parallel)
28+
00:00:00.4350744 Mixed Read/Write (In Parallel)
29+
00:00:00.0125102 Empty Pool (.TryTake())
30+
00:00:01.7061426 TOTAL
31+
32+
33+
Repeat 40000 for size 10
34+
------------------------------------
35+
36+
LinkedListObjectPool....................................
37+
00:00:00.3156256 Take From Empty (In Parallel)
38+
00:00:00.9093478 Give To (In Parallel)
39+
00:00:00.2870968 Mixed Read/Write (In Parallel)
40+
00:00:00.0910514 Empty Pool (.TryTake())
41+
00:00:01.6031216 TOTAL
42+
43+
QueueObjectPool.........................................
44+
00:00:00.3046181 Take From Empty (In Parallel)
45+
00:00:00.5989796 Give To (In Parallel)
46+
00:00:00.2916924 Mixed Read/Write (In Parallel)
47+
00:00:00.0818583 Empty Pool (.TryTake())
48+
00:00:01.2771484 TOTAL
49+
50+
OptimisticArrayObjectPool...............................
51+
00:00:00.2974992 Take From Empty (In Parallel)
52+
00:00:00.4454928 Give To (In Parallel)
53+
00:00:00.2784509 Mixed Read/Write (In Parallel)
54+
00:00:00.0055634 Empty Pool (.TryTake())
55+
00:00:01.0270063 TOTAL
56+
57+
InterlockedArrayObjectPool..............................
58+
00:00:00.3093777 Take From Empty (In Parallel)
59+
00:00:00.4456445 Give To (In Parallel)
60+
00:00:00.2606044 Mixed Read/Write (In Parallel)
61+
00:00:00.0054850 Empty Pool (.TryTake())
62+
00:00:01.0211116 TOTAL
63+
64+
65+
Repeat 8000 for size 100
66+
------------------------------------
67+
68+
LinkedListObjectPool....................................
69+
00:00:00.5553015 Take From Empty (In Parallel)
70+
00:00:01.9316093 Give To (In Parallel)
71+
00:00:00.3668134 Mixed Read/Write (In Parallel)
72+
00:00:00.1489426 Empty Pool (.TryTake())
73+
00:00:03.0026668 TOTAL
74+
75+
QueueObjectPool.........................................
76+
00:00:00.1716840 Take From Empty (In Parallel)
77+
00:00:01.0170214 Give To (In Parallel)
78+
00:00:00.2434091 Mixed Read/Write (In Parallel)
79+
00:00:00.1359503 Empty Pool (.TryTake())
80+
00:00:01.5680648 TOTAL
81+
82+
OptimisticArrayObjectPool...............................
83+
00:00:00.1624457 Take From Empty (In Parallel)
84+
00:00:00.8488803 Give To (In Parallel)
85+
00:00:00.1241455 Mixed Read/Write (In Parallel)
86+
00:00:00.0012911 Empty Pool (.TryTake())
87+
00:00:01.1367626 TOTAL
88+
89+
InterlockedArrayObjectPool..............................
90+
00:00:00.1695044 Take From Empty (In Parallel)
91+
00:00:00.8771345 Give To (In Parallel)
92+
00:00:00.1562285 Mixed Read/Write (In Parallel)
93+
00:00:00.0012742 Empty Pool (.TryTake())
94+
00:00:01.2041416 TOTAL
95+
96+
97+
Repeat 6400 for size 250
98+
------------------------------------
99+
100+
LinkedListObjectPool....................................
101+
00:00:00.6692530 Take From Empty (In Parallel)
102+
00:00:02.7319705 Give To (In Parallel)
103+
00:00:00.7335461 Mixed Read/Write (In Parallel)
104+
00:00:00.2487210 Empty Pool (.TryTake())
105+
00:00:04.3834906 TOTAL
106+
107+
QueueObjectPool.........................................
108+
00:00:00.2190198 Take From Empty (In Parallel)
109+
00:00:01.5061960 Give To (In Parallel)
110+
00:00:00.5232603 Mixed Read/Write (In Parallel)
111+
00:00:00.2279745 Empty Pool (.TryTake())
112+
00:00:02.4764506 TOTAL
113+
114+
OptimisticArrayObjectPool...............................
115+
00:00:00.2007165 Take From Empty (In Parallel)
116+
00:00:01.5293083 Give To (In Parallel)
117+
00:00:00.1518310 Mixed Read/Write (In Parallel)
118+
00:00:00.0010455 Empty Pool (.TryTake())
119+
00:00:01.8829013 TOTAL
120+
121+
InterlockedArrayObjectPool..............................
122+
00:00:00.2396147 Take From Empty (In Parallel)
123+
00:00:01.1445379 Give To (In Parallel)
124+
00:00:00.1543305 Mixed Read/Write (In Parallel)
125+
00:00:00.0010398 Empty Pool (.TryTake())
126+
00:00:01.5395229 TOTAL
127+
128+
129+
Repeat 2400 for size 1000
130+
------------------------------------
131+
132+
LinkedListObjectPool....................................
133+
00:00:00.6898274 Take From Empty (In Parallel)
134+
00:00:02.7620878 Give To (In Parallel)
135+
00:00:00.7002608 Mixed Read/Write (In Parallel)
136+
00:00:00.3406904 Empty Pool (.TryTake())
137+
00:00:04.4928664 TOTAL
138+
139+
QueueObjectPool.........................................
140+
00:00:00.2654685 Take From Empty (In Parallel)
141+
00:00:01.4643862 Give To (In Parallel)
142+
00:00:00.6240877 Mixed Read/Write (In Parallel)
143+
00:00:00.3147795 Empty Pool (.TryTake())
144+
00:00:02.6687219 TOTAL
145+
146+
OptimisticArrayObjectPool...............................
147+
00:00:00.2447782 Take From Empty (In Parallel)
148+
00:00:00.9322246 Give To (In Parallel)
149+
00:00:00.2032299 Mixed Read/Write (In Parallel)
150+
00:00:00.0004221 Empty Pool (.TryTake())
151+
00:00:01.3806548 TOTAL
152+
153+
InterlockedArrayObjectPool..............................
154+
00:00:00.2853462 Take From Empty (In Parallel)
155+
00:00:01.2585180 Give To (In Parallel)
156+
00:00:00.1559039 Mixed Read/Write (In Parallel)
157+
00:00:00.0004293 Empty Pool (.TryTake())
158+
00:00:01.7001974 TOTAL
159+
160+
161+
Repeat 1600 for size 2000
162+
------------------------------------
163+
164+
LinkedListObjectPool....................................
165+
00:00:00.8748769 Take From Empty (In Parallel)
166+
00:00:03.8644551 Give To (In Parallel)
167+
00:00:00.7567420 Mixed Read/Write (In Parallel)
168+
00:00:00.4499334 Empty Pool (.TryTake())
169+
00:00:05.9460074 TOTAL
170+
171+
QueueObjectPool.........................................
172+
00:00:00.2797688 Take From Empty (In Parallel)
173+
00:00:01.5554051 Give To (In Parallel)
174+
00:00:00.6034681 Mixed Read/Write (In Parallel)
175+
00:00:00.4108724 Empty Pool (.TryTake())
176+
00:00:02.8495144 TOTAL
177+
178+
OptimisticArrayObjectPool...............................
179+
00:00:00.2842929 Take From Empty (In Parallel)
180+
00:00:00.9583302 Give To (In Parallel)
181+
00:00:00.2346078 Mixed Read/Write (In Parallel)
182+
00:00:00.0002284 Empty Pool (.TryTake())
183+
00:00:01.4774593 TOTAL
184+
185+
InterlockedArrayObjectPool..............................
186+
00:00:00.3133074 Take From Empty (In Parallel)
187+
00:00:00.8566891 Give To (In Parallel)
188+
00:00:00.2569553 Mixed Read/Write (In Parallel)
189+
00:00:00.0002253 Empty Pool (.TryTake())
190+
00:00:01.4271771 TOTAL
191+
192+
193+
Repeat 1200 for size 4000
194+
------------------------------------
195+
196+
LinkedListObjectPool....................................
197+
00:00:01.1456541 Take From Empty (In Parallel)
198+
00:00:04.5720859 Give To (In Parallel)
199+
00:00:01.2698255 Mixed Read/Write (In Parallel)
200+
00:00:00.6735988 Empty Pool (.TryTake())
201+
00:00:07.6611643 TOTAL
202+
203+
QueueObjectPool.........................................
204+
00:00:00.4444606 Take From Empty (In Parallel)
205+
00:00:02.3798676 Give To (In Parallel)
206+
00:00:00.7691414 Mixed Read/Write (In Parallel)
207+
00:00:00.6140109 Empty Pool (.TryTake())
208+
00:00:04.2074805 TOTAL
209+
210+
OptimisticArrayObjectPool...............................
211+
00:00:00.4147611 Take From Empty (In Parallel)
212+
00:00:01.3839442 Give To (In Parallel)
213+
00:00:00.3031743 Mixed Read/Write (In Parallel)
214+
00:00:00.0001707 Empty Pool (.TryTake())
215+
00:00:02.1020503 TOTAL
216+
217+
InterlockedArrayObjectPool..............................
218+
00:00:00.3761099 Take From Empty (In Parallel)
219+
00:00:01.4896086 Give To (In Parallel)
220+
00:00:00.3215933 Mixed Read/Write (In Parallel)
221+
00:00:00.0001772 Empty Pool (.TryTake())
222+
00:00:02.1874890 TOTAL
223+
224+

benchmarking/OldTest.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Open.Collections;
2+
using System;
3+
using System.Collections.Concurrent;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
7+
namespace Open.Disposable
8+
{
9+
public class OldTest
10+
{
11+
static void Test()
12+
{
13+
var ts = new CancellationTokenSource();
14+
ts.Cancel();
15+
var task = Task.FromResult(ts.Token);
16+
17+
18+
var pool = BufferBlockObjectPool.Create(() => new object(), 1024);
19+
var trimmer = new ObjectPoolAutoTrimmer(20, pool);
20+
var clearer = new ObjectPoolAutoTrimmer(0, pool, TimeSpan.FromSeconds(5));
21+
var tank = new ConcurrentBag<object>();
22+
23+
int count = 0;
24+
while (true)
25+
{
26+
Console.WriteLine("Before {0}: {1}, {2}", count, pool.Count, tank.Count);
27+
28+
count++;
29+
tank.Add(pool.Take());
30+
count++;
31+
tank.Add(new object());
32+
count++;
33+
tank.Add(new object());
34+
foreach (var o in tank.TryTakeWhile(c => c.Count > 30))
35+
pool.Give(o);
36+
37+
Console.WriteLine("After {0}: {1}, {2}", count, pool.Count, tank.Count);
38+
39+
if (count % 30 == 0)
40+
{
41+
Thread.Sleep(1000);
42+
}
43+
44+
if (count % 40 == 0)
45+
{
46+
Console.WriteLine("-----------------");
47+
Thread.Sleep(11000);
48+
}
49+
50+
Console.WriteLine();
51+
52+
}
53+
54+
}
55+
}
56+
}

benchmarking/Open.Disposable.ObjectPools.Benchmarking.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
<RootNamespace>Open.Disposable</RootNamespace>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<Compile Remove="OldTest.cs" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Open.Text.CSV" Version="1.0.1" />
15+
</ItemGroup>
16+
917
<ItemGroup>
1018
<ProjectReference Include="..\source\Open.Disposable.ObjectPools.csproj" />
1119
</ItemGroup>

0 commit comments

Comments
 (0)