Skip to content

Commit 00abe50

Browse files
author
Oren (electricessence)
committed
Revisoins
1 parent a7c46db commit 00abe50

7 files changed

Lines changed: 176 additions & 138 deletions

benchmarking/BenchmarkResult.csv

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
Batch,Pool Type," To (In Parallel)",d 90%-Take/10%-Give (In Parallel),d 50%-Take/50%-Give (In Parallel),d 10%-Take/90%-Give (In Parallel),y Pool (.TryTake()),L,
2-
Repeat 400000 for size 4,ConcurrentQueueObjectPool,00:00:01.8472469,00:00:01.7363986,00:00:01.6837968,00:00:01.7096510,00:00:00.1076125,00:00:07.0847058,
3-
Repeat 400000 for size 4,ConcurrentStackObjectPool,00:00:01.8102817,00:00:01.7426871,00:00:01.6518815,00:00:01.8414613,00:00:00.1049529,00:00:07.1512645,
4-
Repeat 400000 for size 4,OptimisticArrayObjectPool,00:00:01.8589242,00:00:01.7585402,00:00:01.7489384,00:00:01.7687298,00:00:00.0952550,00:00:07.2303876,
5-
Repeat 160000 for size 10,ConcurrentQueueObjectPool,00:00:00.7782376,00:00:00.7324783,00:00:00.7163121,00:00:00.7306797,00:00:00.0971813,00:00:03.0548890,
6-
Repeat 160000 for size 10,ConcurrentStackObjectPool,00:00:00.9064832,00:00:00.7690028,00:00:00.7207622,00:00:00.8417267,00:00:00.1034971,00:00:03.3414720,
7-
Repeat 160000 for size 10,OptimisticArrayObjectPool,00:00:00.8577028,00:00:00.7887449,00:00:00.7333412,00:00:00.8531175,00:00:00.1088223,00:00:03.3417287,
8-
Repeat 48000 for size 50,ConcurrentQueueObjectPool,00:00:00.4952668,00:00:00.3843341,00:00:00.3179560,00:00:00.3515590,00:00:00.1171762,00:00:01.6662921,
9-
Repeat 48000 for size 50,ConcurrentStackObjectPool,00:00:00.5346734,00:00:00.3824365,00:00:00.3211063,00:00:00.4865511,00:00:00.1248121,00:00:01.8495794,
10-
Repeat 48000 for size 50,OptimisticArrayObjectPool,00:00:00.5833078,00:00:00.4477068,00:00:00.3296106,00:00:00.4408652,00:00:00.3016180,00:00:02.1031084,
11-
Repeat 32000 for size 100,ConcurrentQueueObjectPool,00:00:00.4969536,00:00:00.4326518,00:00:00.3199614,00:00:00.4396957,00:00:00.1608001,00:00:01.8500626,
12-
Repeat 32000 for size 100,ConcurrentStackObjectPool,00:00:00.5521412,00:00:00.4853524,00:00:00.3175640,00:00:00.5159456,00:00:00.1572408,00:00:02.0282440,
13-
Repeat 32000 for size 100,OptimisticArrayObjectPool,00:00:00.7719640,00:00:00.5488668,00:00:00.2717297,00:00:00.5357692,00:00:00.6489823,00:00:02.7773120,
14-
Repeat 25600 for size 250,ConcurrentQueueObjectPool,00:00:00.7980353,00:00:00.6178042,00:00:00.5431682,00:00:00.6892625,00:00:00.2954847,00:00:02.9437549,
15-
Repeat 25600 for size 250,ConcurrentStackObjectPool,00:00:00.9389921,00:00:00.9667758,00:00:00.5609015,00:00:00.8204988,00:00:00.3075525,00:00:03.5947207,
16-
Repeat 25600 for size 250,OptimisticArrayObjectPool,00:00:02.1193418,00:00:01.3828499,00:00:00.4523577,00:00:01.3159924,00:00:02.9909843,00:00:08.2615261,
17-
Repeat 6400 for size 2000,ConcurrentQueueObjectPool,00:00:01.3830355,00:00:00.9243686,00:00:00.9780430,00:00:00.9865309,00:00:00.5832766,00:00:04.8552546,
18-
Repeat 6400 for size 2000,ConcurrentStackObjectPool,00:00:01.6064533,00:00:02.5455114,00:00:01.2388087,00:00:01.5112497,00:00:00.5781890,00:00:07.4802121,
19-
Repeat 6400 for size 2000,OptimisticArrayObjectPool,00:00:13.5147753,00:00:15.1956294,00:00:00.9013497,00:00:12.0385696,00:00:32.8558145,00:01:14.5061385,
20-
for size 2000,ConcurrentStackObjectPool,00:00:01.4597004,00:00:01.7435741,00:00:02.4213177,00:00:01.0803513,00:00:01.6261815,00:00:00.6094295,00:00:08.9405545,
21-
Repeat 6400 for size 2000,OptimisticArrayObjectPool,00:00:01.2265087,00:00:23.0488821,00:00:15.8054484,00:00:00.9435990,00:00:14.8800972,00:00:51.4640465,00:01:47.3685819,
2+
Repeat 120000 for size 4,ConcurrentQueueObjectPool,00:00:00.4328809,00:00:00.4157680,00:00:00.4065244,00:00:00.4045626,00:00:00.0271763,00:00:01.6869122,
3+
Repeat 120000 for size 4,ConcurrentStackObjectPool,00:00:01.0126419,00:00:00.9358291,00:00:00.9317805,00:00:00.9543443,00:00:00.0426221,00:00:03.8772179,
4+
Repeat 120000 for size 4,OptimisticArrayObjectPool,00:00:00.3072837,00:00:00.2791047,00:00:00.2824113,00:00:00.2763940,00:00:00.0181322,00:00:01.1633259,
5+
Repeat 120000 for size 4,InterlockedArrayObjectPool,00:00:00.2849269,00:00:00.2799949,00:00:00.2987070,00:00:00.2980612,00:00:00.0179067,00:00:01.1795967,
6+
Repeat 48000 for size 10,ConcurrentQueueObjectPool,00:00:00.2049617,00:00:00.1879537,00:00:00.1863383,00:00:00.1791973,00:00:00.0187886,00:00:00.7772396,
7+
Repeat 48000 for size 10,ConcurrentStackObjectPool,00:00:00.2312536,00:00:00.2063132,00:00:00.1973173,00:00:00.2137496,00:00:00.0209974,00:00:00.8696311,
8+
Repeat 48000 for size 10,OptimisticArrayObjectPool,00:00:00.1948958,00:00:00.1866085,00:00:00.1851642,00:00:00.1743788,00:00:00.0212318,00:00:00.7622791,
9+
Repeat 48000 for size 10,InterlockedArrayObjectPool,00:00:00.2025915,00:00:00.1947096,00:00:00.1832321,00:00:00.1855078,00:00:00.0213919,00:00:00.7874329,
10+
Repeat 14400 for size 50,ConcurrentQueueObjectPool,00:00:00.1153192,00:00:00.0930024,00:00:00.0847000,00:00:00.0976083,00:00:00.0225625,00:00:00.4131924,
11+
Repeat 14400 for size 50,ConcurrentStackObjectPool,00:00:00.1210192,00:00:00.0938168,00:00:00.0859916,00:00:00.1097679,00:00:00.0232161,00:00:00.4338116,
12+
Repeat 14400 for size 50,OptimisticArrayObjectPool,00:00:00.1162956,00:00:00.1051234,00:00:00.0809849,00:00:00.0920824,00:00:00.0592899,00:00:00.4537762,
13+
Repeat 14400 for size 50,InterlockedArrayObjectPool,00:00:00.1351777,00:00:00.1015328,00:00:00.0834721,00:00:00.1115662,00:00:00.0940603,00:00:00.5258091,
14+
Repeat 9600 for size 100,ConcurrentQueueObjectPool,00:00:00.1223762,00:00:00.0972226,00:00:00.0758479,00:00:00.0921301,00:00:00.0327353,00:00:00.4203121,
15+
Repeat 9600 for size 100,ConcurrentStackObjectPool,00:00:00.1517036,00:00:00.2118948,00:00:00.1054921,00:00:00.1368268,00:00:00.0473453,00:00:00.6532626,
16+
Repeat 9600 for size 100,OptimisticArrayObjectPool,00:00:00.1073093,00:00:00.1045937,00:00:00.0705415,00:00:00.0824673,00:00:00.0956365,00:00:00.4605483,
17+
Repeat 9600 for size 100,InterlockedArrayObjectPool,00:00:00.1494063,00:00:00.1077739,00:00:00.0746742,00:00:00.1128479,00:00:00.2238334,00:00:00.6685357,
18+
Repeat 7680 for size 250,ConcurrentQueueObjectPool,00:00:00.2123888,00:00:00.1725807,00:00:00.1277665,00:00:00.1629961,00:00:00.0699733,00:00:00.7457054,
19+
Repeat 7680 for size 250,ConcurrentStackObjectPool,00:00:00.7008323,00:00:03.4680108,00:00:00.7312092,00:00:00.7532056,00:00:00.2733349,00:00:05.9265928,
20+
Repeat 7680 for size 250,OptimisticArrayObjectPool,00:00:00.2225184,00:00:00.2290041,00:00:00.1110785,00:00:00.1400907,00:00:00.3309545,00:00:01.0336462,
21+
Repeat 7680 for size 250,InterlockedArrayObjectPool,00:00:00.4984438,00:00:00.2336851,00:00:00.1059643,00:00:00.2670714,00:00:00.8555392,00:00:01.9607038,
22+
:51.4640465,00:01:47.3685819,
2223
,
2324
epeat 51200 for size 250,OptimisticArrayObjectPool,00:00:00.7651948,00:00:01.3195712,00:00:01.3758641,00:00:00.6837150,00:00:01.0134658,00:00:01.9616149,00:00:07.1194258,
2425
Repeat 51200 for size 250,InterlockedArrayObjectPool,00:00:00.8386708,00:00:02.2800174,00:00:01.4244575,00:00:00.6435472,00:00:01.6845873,00:00:05.4327218,00:00:12.3040020,

benchmarking/BenchmarkResult.txt

Lines changed: 143 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,180 @@
1-
Repeat 400000 for size 4
1+
Repeat 120000 for size 4
22
------------------------------------
33

44
ConcurrentQueueObjectPool...............................
5-
00:00:01.8472469 Give To (In Parallel)
6-
00:00:01.7363986 Mixed 90%-Take/10%-Give (In Parallel)
7-
00:00:01.6837968 Mixed 50%-Take/50%-Give (In Parallel)
8-
00:00:01.7096510 Mixed 10%-Take/90%-Give (In Parallel)
9-
00:00:00.1076125 Empty Pool (.TryTake())
10-
00:00:07.0847058 TOTAL
5+
00:00:00.4328809 Give To (In Parallel)
6+
00:00:00.4157680 Mixed 90%-Take/10%-Give (In Parallel)
7+
00:00:00.4065244 Mixed 50%-Take/50%-Give (In Parallel)
8+
00:00:00.4045626 Mixed 10%-Take/90%-Give (In Parallel)
9+
00:00:00.0271763 Empty Pool (.TryTake())
10+
00:00:01.6869122 TOTAL
1111

1212
ConcurrentStackObjectPool...............................
13-
00:00:01.8102817 Give To (In Parallel)
14-
00:00:01.7426871 Mixed 90%-Take/10%-Give (In Parallel)
15-
00:00:01.6518815 Mixed 50%-Take/50%-Give (In Parallel)
16-
00:00:01.8414613 Mixed 10%-Take/90%-Give (In Parallel)
17-
00:00:00.1049529 Empty Pool (.TryTake())
18-
00:00:07.1512645 TOTAL
13+
00:00:01.0126419 Give To (In Parallel)
14+
00:00:00.9358291 Mixed 90%-Take/10%-Give (In Parallel)
15+
00:00:00.9317805 Mixed 50%-Take/50%-Give (In Parallel)
16+
00:00:00.9543443 Mixed 10%-Take/90%-Give (In Parallel)
17+
00:00:00.0426221 Empty Pool (.TryTake())
18+
00:00:03.8772179 TOTAL
1919

2020
OptimisticArrayObjectPool...............................
21-
00:00:01.8589242 Give To (In Parallel)
22-
00:00:01.7585402 Mixed 90%-Take/10%-Give (In Parallel)
23-
00:00:01.7489384 Mixed 50%-Take/50%-Give (In Parallel)
24-
00:00:01.7687298 Mixed 10%-Take/90%-Give (In Parallel)
25-
00:00:00.0952550 Empty Pool (.TryTake())
26-
00:00:07.2303876 TOTAL
27-
28-
29-
Repeat 160000 for size 10
21+
00:00:00.3072837 Give To (In Parallel)
22+
00:00:00.2791047 Mixed 90%-Take/10%-Give (In Parallel)
23+
00:00:00.2824113 Mixed 50%-Take/50%-Give (In Parallel)
24+
00:00:00.2763940 Mixed 10%-Take/90%-Give (In Parallel)
25+
00:00:00.0181322 Empty Pool (.TryTake())
26+
00:00:01.1633259 TOTAL
27+
28+
InterlockedArrayObjectPool..............................
29+
00:00:00.2849269 Give To (In Parallel)
30+
00:00:00.2799949 Mixed 90%-Take/10%-Give (In Parallel)
31+
00:00:00.2987070 Mixed 50%-Take/50%-Give (In Parallel)
32+
00:00:00.2980612 Mixed 10%-Take/90%-Give (In Parallel)
33+
00:00:00.0179067 Empty Pool (.TryTake())
34+
00:00:01.1795967 TOTAL
35+
36+
37+
Repeat 48000 for size 10
3038
------------------------------------
3139

3240
ConcurrentQueueObjectPool...............................
33-
00:00:00.7782376 Give To (In Parallel)
34-
00:00:00.7324783 Mixed 90%-Take/10%-Give (In Parallel)
35-
00:00:00.7163121 Mixed 50%-Take/50%-Give (In Parallel)
36-
00:00:00.7306797 Mixed 10%-Take/90%-Give (In Parallel)
37-
00:00:00.0971813 Empty Pool (.TryTake())
38-
00:00:03.0548890 TOTAL
41+
00:00:00.2049617 Give To (In Parallel)
42+
00:00:00.1879537 Mixed 90%-Take/10%-Give (In Parallel)
43+
00:00:00.1863383 Mixed 50%-Take/50%-Give (In Parallel)
44+
00:00:00.1791973 Mixed 10%-Take/90%-Give (In Parallel)
45+
00:00:00.0187886 Empty Pool (.TryTake())
46+
00:00:00.7772396 TOTAL
3947

4048
ConcurrentStackObjectPool...............................
41-
00:00:00.9064832 Give To (In Parallel)
42-
00:00:00.7690028 Mixed 90%-Take/10%-Give (In Parallel)
43-
00:00:00.7207622 Mixed 50%-Take/50%-Give (In Parallel)
44-
00:00:00.8417267 Mixed 10%-Take/90%-Give (In Parallel)
45-
00:00:00.1034971 Empty Pool (.TryTake())
46-
00:00:03.3414720 TOTAL
49+
00:00:00.2312536 Give To (In Parallel)
50+
00:00:00.2063132 Mixed 90%-Take/10%-Give (In Parallel)
51+
00:00:00.1973173 Mixed 50%-Take/50%-Give (In Parallel)
52+
00:00:00.2137496 Mixed 10%-Take/90%-Give (In Parallel)
53+
00:00:00.0209974 Empty Pool (.TryTake())
54+
00:00:00.8696311 TOTAL
4755

4856
OptimisticArrayObjectPool...............................
49-
00:00:00.8577028 Give To (In Parallel)
50-
00:00:00.7887449 Mixed 90%-Take/10%-Give (In Parallel)
51-
00:00:00.7333412 Mixed 50%-Take/50%-Give (In Parallel)
52-
00:00:00.8531175 Mixed 10%-Take/90%-Give (In Parallel)
53-
00:00:00.1088223 Empty Pool (.TryTake())
54-
00:00:03.3417287 TOTAL
55-
56-
57-
Repeat 48000 for size 50
57+
00:00:00.1948958 Give To (In Parallel)
58+
00:00:00.1866085 Mixed 90%-Take/10%-Give (In Parallel)
59+
00:00:00.1851642 Mixed 50%-Take/50%-Give (In Parallel)
60+
00:00:00.1743788 Mixed 10%-Take/90%-Give (In Parallel)
61+
00:00:00.0212318 Empty Pool (.TryTake())
62+
00:00:00.7622791 TOTAL
63+
64+
InterlockedArrayObjectPool..............................
65+
00:00:00.2025915 Give To (In Parallel)
66+
00:00:00.1947096 Mixed 90%-Take/10%-Give (In Parallel)
67+
00:00:00.1832321 Mixed 50%-Take/50%-Give (In Parallel)
68+
00:00:00.1855078 Mixed 10%-Take/90%-Give (In Parallel)
69+
00:00:00.0213919 Empty Pool (.TryTake())
70+
00:00:00.7874329 TOTAL
71+
72+
73+
Repeat 14400 for size 50
5874
------------------------------------
5975

6076
ConcurrentQueueObjectPool...............................
61-
00:00:00.4952668 Give To (In Parallel)
62-
00:00:00.3843341 Mixed 90%-Take/10%-Give (In Parallel)
63-
00:00:00.3179560 Mixed 50%-Take/50%-Give (In Parallel)
64-
00:00:00.3515590 Mixed 10%-Take/90%-Give (In Parallel)
65-
00:00:00.1171762 Empty Pool (.TryTake())
66-
00:00:01.6662921 TOTAL
77+
00:00:00.1153192 Give To (In Parallel)
78+
00:00:00.0930024 Mixed 90%-Take/10%-Give (In Parallel)
79+
00:00:00.0847000 Mixed 50%-Take/50%-Give (In Parallel)
80+
00:00:00.0976083 Mixed 10%-Take/90%-Give (In Parallel)
81+
00:00:00.0225625 Empty Pool (.TryTake())
82+
00:00:00.4131924 TOTAL
6783

6884
ConcurrentStackObjectPool...............................
69-
00:00:00.5346734 Give To (In Parallel)
70-
00:00:00.3824365 Mixed 90%-Take/10%-Give (In Parallel)
71-
00:00:00.3211063 Mixed 50%-Take/50%-Give (In Parallel)
72-
00:00:00.4865511 Mixed 10%-Take/90%-Give (In Parallel)
73-
00:00:00.1248121 Empty Pool (.TryTake())
74-
00:00:01.8495794 TOTAL
85+
00:00:00.1210192 Give To (In Parallel)
86+
00:00:00.0938168 Mixed 90%-Take/10%-Give (In Parallel)
87+
00:00:00.0859916 Mixed 50%-Take/50%-Give (In Parallel)
88+
00:00:00.1097679 Mixed 10%-Take/90%-Give (In Parallel)
89+
00:00:00.0232161 Empty Pool (.TryTake())
90+
00:00:00.4338116 TOTAL
7591

7692
OptimisticArrayObjectPool...............................
77-
00:00:00.5833078 Give To (In Parallel)
78-
00:00:00.4477068 Mixed 90%-Take/10%-Give (In Parallel)
79-
00:00:00.3296106 Mixed 50%-Take/50%-Give (In Parallel)
80-
00:00:00.4408652 Mixed 10%-Take/90%-Give (In Parallel)
81-
00:00:00.3016180 Empty Pool (.TryTake())
82-
00:00:02.1031084 TOTAL
83-
84-
85-
Repeat 32000 for size 100
93+
00:00:00.1162956 Give To (In Parallel)
94+
00:00:00.1051234 Mixed 90%-Take/10%-Give (In Parallel)
95+
00:00:00.0809849 Mixed 50%-Take/50%-Give (In Parallel)
96+
00:00:00.0920824 Mixed 10%-Take/90%-Give (In Parallel)
97+
00:00:00.0592899 Empty Pool (.TryTake())
98+
00:00:00.4537762 TOTAL
99+
100+
InterlockedArrayObjectPool..............................
101+
00:00:00.1351777 Give To (In Parallel)
102+
00:00:00.1015328 Mixed 90%-Take/10%-Give (In Parallel)
103+
00:00:00.0834721 Mixed 50%-Take/50%-Give (In Parallel)
104+
00:00:00.1115662 Mixed 10%-Take/90%-Give (In Parallel)
105+
00:00:00.0940603 Empty Pool (.TryTake())
106+
00:00:00.5258091 TOTAL
107+
108+
109+
Repeat 9600 for size 100
86110
------------------------------------
87111

88112
ConcurrentQueueObjectPool...............................
89-
00:00:00.4969536 Give To (In Parallel)
90-
00:00:00.4326518 Mixed 90%-Take/10%-Give (In Parallel)
91-
00:00:00.3199614 Mixed 50%-Take/50%-Give (In Parallel)
92-
00:00:00.4396957 Mixed 10%-Take/90%-Give (In Parallel)
93-
00:00:00.1608001 Empty Pool (.TryTake())
94-
00:00:01.8500626 TOTAL
113+
00:00:00.1223762 Give To (In Parallel)
114+
00:00:00.0972226 Mixed 90%-Take/10%-Give (In Parallel)
115+
00:00:00.0758479 Mixed 50%-Take/50%-Give (In Parallel)
116+
00:00:00.0921301 Mixed 10%-Take/90%-Give (In Parallel)
117+
00:00:00.0327353 Empty Pool (.TryTake())
118+
00:00:00.4203121 TOTAL
95119

96120
ConcurrentStackObjectPool...............................
97-
00:00:00.5521412 Give To (In Parallel)
98-
00:00:00.4853524 Mixed 90%-Take/10%-Give (In Parallel)
99-
00:00:00.3175640 Mixed 50%-Take/50%-Give (In Parallel)
100-
00:00:00.5159456 Mixed 10%-Take/90%-Give (In Parallel)
101-
00:00:00.1572408 Empty Pool (.TryTake())
102-
00:00:02.0282440 TOTAL
121+
00:00:00.1517036 Give To (In Parallel)
122+
00:00:00.2118948 Mixed 90%-Take/10%-Give (In Parallel)
123+
00:00:00.1054921 Mixed 50%-Take/50%-Give (In Parallel)
124+
00:00:00.1368268 Mixed 10%-Take/90%-Give (In Parallel)
125+
00:00:00.0473453 Empty Pool (.TryTake())
126+
00:00:00.6532626 TOTAL
103127

104128
OptimisticArrayObjectPool...............................
105-
00:00:00.7719640 Give To (In Parallel)
106-
00:00:00.5488668 Mixed 90%-Take/10%-Give (In Parallel)
107-
00:00:00.2717297 Mixed 50%-Take/50%-Give (In Parallel)
108-
00:00:00.5357692 Mixed 10%-Take/90%-Give (In Parallel)
109-
00:00:00.6489823 Empty Pool (.TryTake())
110-
00:00:02.7773120 TOTAL
111-
112-
113-
Repeat 25600 for size 250
129+
00:00:00.1073093 Give To (In Parallel)
130+
00:00:00.1045937 Mixed 90%-Take/10%-Give (In Parallel)
131+
00:00:00.0705415 Mixed 50%-Take/50%-Give (In Parallel)
132+
00:00:00.0824673 Mixed 10%-Take/90%-Give (In Parallel)
133+
00:00:00.0956365 Empty Pool (.TryTake())
134+
00:00:00.4605483 TOTAL
135+
136+
InterlockedArrayObjectPool..............................
137+
00:00:00.1494063 Give To (In Parallel)
138+
00:00:00.1077739 Mixed 90%-Take/10%-Give (In Parallel)
139+
00:00:00.0746742 Mixed 50%-Take/50%-Give (In Parallel)
140+
00:00:00.1128479 Mixed 10%-Take/90%-Give (In Parallel)
141+
00:00:00.2238334 Empty Pool (.TryTake())
142+
00:00:00.6685357 TOTAL
143+
144+
145+
Repeat 7680 for size 250
114146
------------------------------------
115147

116148
ConcurrentQueueObjectPool...............................
117-
00:00:00.7980353 Give To (In Parallel)
118-
00:00:00.6178042 Mixed 90%-Take/10%-Give (In Parallel)
119-
00:00:00.5431682 Mixed 50%-Take/50%-Give (In Parallel)
120-
00:00:00.6892625 Mixed 10%-Take/90%-Give (In Parallel)
121-
00:00:00.2954847 Empty Pool (.TryTake())
122-
00:00:02.9437549 TOTAL
149+
00:00:00.2123888 Give To (In Parallel)
150+
00:00:00.1725807 Mixed 90%-Take/10%-Give (In Parallel)
151+
00:00:00.1277665 Mixed 50%-Take/50%-Give (In Parallel)
152+
00:00:00.1629961 Mixed 10%-Take/90%-Give (In Parallel)
153+
00:00:00.0699733 Empty Pool (.TryTake())
154+
00:00:00.7457054 TOTAL
123155

124156
ConcurrentStackObjectPool...............................
125-
00:00:00.9389921 Give To (In Parallel)
126-
00:00:00.9667758 Mixed 90%-Take/10%-Give (In Parallel)
127-
00:00:00.5609015 Mixed 50%-Take/50%-Give (In Parallel)
128-
00:00:00.8204988 Mixed 10%-Take/90%-Give (In Parallel)
129-
00:00:00.3075525 Empty Pool (.TryTake())
130-
00:00:03.5947207 TOTAL
157+
00:00:00.7008323 Give To (In Parallel)
158+
00:00:03.4680108 Mixed 90%-Take/10%-Give (In Parallel)
159+
00:00:00.7312092 Mixed 50%-Take/50%-Give (In Parallel)
160+
00:00:00.7532056 Mixed 10%-Take/90%-Give (In Parallel)
161+
00:00:00.2733349 Empty Pool (.TryTake())
162+
00:00:05.9265928 TOTAL
131163

132164
OptimisticArrayObjectPool...............................
133-
00:00:02.1193418 Give To (In Parallel)
134-
00:00:01.3828499 Mixed 90%-Take/10%-Give (In Parallel)
135-
00:00:00.4523577 Mixed 50%-Take/50%-Give (In Parallel)
136-
00:00:01.3159924 Mixed 10%-Take/90%-Give (In Parallel)
137-
00:00:02.9909843 Empty Pool (.TryTake())
138-
00:00:08.2615261 TOTAL
165+
00:00:00.2225184 Give To (In Parallel)
166+
00:00:00.2290041 Mixed 90%-Take/10%-Give (In Parallel)
167+
00:00:00.1110785 Mixed 50%-Take/50%-Give (In Parallel)
168+
00:00:00.1400907 Mixed 10%-Take/90%-Give (In Parallel)
169+
00:00:00.3309545 Empty Pool (.TryTake())
170+
00:00:01.0336462 TOTAL
171+
172+
InterlockedArrayObjectPool..............................
173+
00:00:00.4984438 Give To (In Parallel)
174+
00:00:00.2336851 Mixed 90%-Take/10%-Give (In Parallel)
175+
00:00:00.1059643 Mixed 50%-Take/50%-Give (In Parallel)
176+
00:00:00.2670714 Mixed 10%-Take/90%-Give (In Parallel)
177+
00:00:00.8555392 Empty Pool (.TryTake())
178+
00:00:01.9607038 TOTAL
139179

140180

benchmarking/Open.Disposable.ObjectPools.Benchmarking.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<ItemGroup>
2323
<PackageReference Include="Open.Diagnostics" Version="1.3.0" />
24-
<PackageReference Include="Open.Text.CSV" Version="1.1.0" />
24+
<PackageReference Include="Open.Text.CSV" Version="2.0.0" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

benchmarking/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ static void Main()
2828
//report.AddBenchmark("QueueObjectPool", // Note, that this one isn't far off from the following in peformance.
2929
// count => () => QueueObjectPool.Create<object>((int)count * 2));
3030

31-
//report.AddBenchmark("ChannelObjectPool",
32-
// count => () => ChannelObjectPool.Create<object>((int)count * 2));
31+
report.AddBenchmark("ChannelObjectPool",
32+
count => () => ChannelObjectPool.Create<object>((int)count * 2));
3333

3434
report.AddBenchmark("ConcurrentQueueObjectPool", // Note, that this one isn't far off from the following in peformance, but definitely is faster than LinkedListObjectPool and the rest.
3535
count => () => ConcurrentQueueObjectPool.Create<object>((int)count * 2));

source/Channels/ChannelObjectPool.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ namespace Open.Disposable
66
public sealed class ChannelObjectPool<T> : ObjectPoolBase<T>
77
where T : class
88
{
9-
public ChannelObjectPool(Func<T> factory, Action<T> recycler, int capacity = DEFAULT_CAPACITY)
10-
: base(factory, recycler, capacity)
9+
public ChannelObjectPool(Func<T> factory, Action<T> recycler, Action<T> disposer, int capacity = DEFAULT_CAPACITY)
10+
: base(factory, recycler, disposer, capacity)
1111
{
1212
Pool = Channel.CreateBounded<T>(new BoundedChannelOptions(capacity) { FullMode = BoundedChannelFullMode.DropWrite });
1313
}
1414

1515
public ChannelObjectPool(Func<T> factory, int capacity = DEFAULT_CAPACITY)
16-
: this(factory, null, capacity)
16+
: this(factory, null, null, capacity)
1717
{ }
1818

1919
Channel<T> Pool;
2020

21+
public override int Count => -1;
22+
2123
protected override void OnDispose(bool calledExplicitly)
2224
{
2325
Pool?.Writer.TryComplete();
@@ -56,7 +58,7 @@ public static ChannelObjectPool<T> Create<T>(Func<T> factory, bool autoRecycle,
5658
{
5759
Action<T> recycler = null;
5860
if (autoRecycle) recycler = Recycler.Recycle;
59-
return new ChannelObjectPool<T>(factory, recycler, capacity);
61+
return new ChannelObjectPool<T>(factory, recycler, null, capacity);
6062
}
6163

6264
public static ChannelObjectPool<T> Create<T>(bool autoRecycle, int capacity = Constants.DEFAULT_CAPACITY)

0 commit comments

Comments
 (0)