@@ -22,6 +22,13 @@ def foo(latch = nil)
22
22
end
23
23
end
24
24
25
+ class AsyncAlternateClass
26
+ include Concurrent ::Async
27
+ def foo ( latch = nil )
28
+ latch . count_down if latch
29
+ end
30
+ end
31
+
25
32
IPS_NUM = 100
26
33
BMBM_NUM = 100_000
27
34
@@ -34,7 +41,14 @@ def foo(latch = nil)
34
41
end
35
42
36
43
async = AsyncClass . new
37
- bm . report ( 'async' ) do
44
+ bm . report ( 'async, thread per object' ) do
45
+ latch = Concurrent ::CountDownLatch . new ( IPS_NUM )
46
+ IPS_NUM . times { async . async . foo ( latch ) }
47
+ latch . wait
48
+ end
49
+
50
+ async = AsyncAlternateClass . new
51
+ bm . report ( 'async, global thread pool' ) do
38
52
latch = Concurrent ::CountDownLatch . new ( IPS_NUM )
39
53
IPS_NUM . times { async . async . foo ( latch ) }
40
54
latch . wait
@@ -52,7 +66,14 @@ def foo(latch = nil)
52
66
end
53
67
54
68
async = AsyncClass . new
55
- bm . report ( 'async' ) do
69
+ bm . report ( 'async, thread per object' ) do
70
+ latch = Concurrent ::CountDownLatch . new ( BMBM_NUM )
71
+ BMBM_NUM . times { async . async . foo ( latch ) }
72
+ latch . wait
73
+ end
74
+
75
+ async = AsyncAlternateClass . new
76
+ bm . report ( 'async, global thread pool' ) do
56
77
latch = Concurrent ::CountDownLatch . new ( BMBM_NUM )
57
78
BMBM_NUM . times { async . async . foo ( latch ) }
58
79
latch . wait
@@ -82,45 +103,30 @@ def foo(latch = nil)
82
103
===========================================================
83
104
84
105
Calculating -------------------------------------
85
- celluloid 26.000 i/100ms
86
- async 47.000 i/100ms
87
- -------------------------------------------------
88
- celluloid 279.912 (± 6.1%) i/s - 1.404k
89
- async 478.932 (± 2.1%) i/s - 2.397k
90
-
91
- Comparison:
92
- async: 478.9 i/s
93
- celluloid: 279.9 i/s - 1.71x slower
94
-
95
- Rehearsal ---------------------------------------------
96
- celluloid 4.080000 0.620000 4.700000 ( 4.695271)
97
- async 2.280000 0.100000 2.380000 ( 2.345327)
98
- ------------------------------------ total: 7.080000sec
99
-
100
- user system total real
101
- celluloid 3.910000 0.580000 4.490000 ( 4.503884)
102
- async 2.220000 0.190000 2.410000 ( 2.340467)
103
-
104
- ===========================================================
105
- jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [darwin-x86_64]
106
- ===========================================================
107
-
108
- Calculating -------------------------------------
109
- celluloid 2.000 i/100ms
110
- async 32.000 i/100ms
106
+ celluloid 24.000 i/100ms
107
+ async, thread per object
108
+ 30.000 i/100ms
109
+ async, global thread pool
110
+ 31.000 i/100ms
111
111
-------------------------------------------------
112
- celluloid 72.887 (±26.1%) i/s - 334.000
113
- async 1.822k (±31.6%) i/s - 6.368k
112
+ celluloid 242.345 (±10.7%) i/s - 1.200k
113
+ async, thread per object
114
+ 316.387 (± 2.5%) i/s - 1.590k
115
+ async, global thread pool
116
+ 318.200 (± 1.6%) i/s - 1.612k
114
117
115
118
Comparison:
116
- async: 1821.9 i/s
117
- celluloid: 72.9 i/s - 25.00x slower
118
-
119
- Rehearsal ---------------------------------------------
120
- celluloid 8.890000 1.700000 10.590000 ( 5.930000)
121
- async 2.250000 0.150000 2.400000 ( 1.283000)
122
- ----------------------------------- total: 12.990000sec
123
-
124
- user system total real
125
- celluloid 6.310000 1.530000 7.840000 ( 5.817000)
126
- async 1.590000 0.060000 1.650000 ( 0.912000)
119
+ async, global thread pool: 318.2 i/s
120
+ async, thread per object: 316.4 i/s - 1.01x slower
121
+ celluloid: 242.3 i/s - 1.31x slower
122
+
123
+ Rehearsal -------------------------------------------------------------
124
+ celluloid 4.170000 0.630000 4.800000 ( 4.812120)
125
+ async, thread per object 3.400000 0.110000 3.510000 ( 3.452749)
126
+ async, global thread pool 3.410000 0.070000 3.480000 ( 3.455878)
127
+ --------------------------------------------------- total: 11.790000sec
128
+
129
+ user system total real
130
+ celluloid 4.080000 0.620000 4.700000 ( 4.687752)
131
+ async, thread per object 3.380000 0.160000 3.540000 ( 3.469882)
132
+ async, global thread pool 3.380000 0.050000 3.430000 ( 3.426759)
0 commit comments