Nobu, Thanks a lot for all your improvements! And now, thanks a lot for SizedQueue and ConditionVariable. It was very very helpful. I was studying your improvements to get SizedQueue and ConditionVariable better before sending any patch to the list, but I'm sure that it couldn't be better than what you've showed us now. > So, Ruby implementation seems faster for #empty?, #size and > #num_waiting (and #clear), which are all methods with a simple call to > an Array method. Maybe that's because of change of context. I'm not sure yet, but I'll try to test it a bit more, to see where I can get. On Sun, Jul 18, 2010 at 14:13, Aaron Patterson <aaron / tenderlovemaking.com> wrote: > On Sun, Jul 18, 2010 at 09:43:07PM +0900, Benoit Daloze wrote: >> Hi, >> On 18 July 2010 02:05, Nobuyoshi Nakada <nobu / ruby-lang.org> wrote: >> > Hi, >> > >> > At Sun, 18 Jul 2010 06:00:56 +0900, >> > Ricardo Panaggio wrote in [ruby-core:31333]: >> >> My implementation is almost 4 times faster than the existing one. >> >> Maybe it's enough, maybe it's not. Let me know if it isn't, so that I >> >> can make any extra tuning, if needed. >> > >> > It was 3 and a half faster on my machine. >> > >> > ¨ΒσεσωστενΑ° ¨Βοταμ ¨Βεα>> > ¨Βυευε°°®ΉΉ°°°°®°³°°°° ±®°²°°°° ®°³¶Έµ·© >> > ¨Βυευε±°°°®Ή±°°°°®³²°°°° °®²³°°°° ±°®¶··°³Ή© >> > ¨ΒυευεΊ±°°°°ΉΉ®°±°°°³®±³°°°° ±°²®±΄°°°° ¨±°µ®΄°΄µΈ·© >> > ¨ΒσεσωστενΑ° ¨Βοταμ ¨Βεα>> > Thread::Queue: 00| .280000 0.020000 0.300000 ( .315329) >> > Thread::Queue: 1000| .870000 0.140000 3.010000 ( .050338) >> > Thread::Queue:10000| 28.540000 1.450000 9.990000 ( 30.711049) >> > >> > Thread::Queue is C-implementation. >> > -- >> > Nobu Nakada >> >> 3 times on my machine: >> user system ¨Βοταμ ¨Βεα>> Queue: 100 .380000 0.020000 0.400000 ( .390914) >> Queue: 1000 3.750000 0.130000 3.880000 ( .934827) >> Queue: 10000 37.270000 1.340000 8.610000 ( 39.136691) >> Thread::Queue: 100 .130000 0.000000 0.130000 ( .132765) >> Thread::Queue: 1000 1.260000 0.060000 1.320000 ( .353208) >> Thread::Queue: 10000 12.490000 0.580000 3.070000 ( 13.228104) >> >> (ruby 1.9.3dev (2010-07-18 trunk 28676) [x86_64-darwin10.4.0] with the >> patch of Nobu) >> >> Just for the fun, I did another benchmark to compare method by method, >> running each N time (this is obviously not real word use). >> #clear is using #push(N/2 times), so results are exaggerated for Ruby >> (actually Ruby beats C if it is only N.times{q.clear}). >> (See http://gist.github.com/480359) >> Q is Queue, T is Thread::Queue (C) >> user system ¨Βοταμ ¨Βεα>> Q#push .810000 0.000000 0.810000 ( .818967) >> T#push .350000 0.000000 0.350000 ( .369173) >> Q#pop 1.710000 0.010000 1.720000 ( .719467) >> T#pop 0.340000 0.000000 0.340000 ( .344720) >> Q#empty? .200000 0.000000 0.200000 ( .202756) >> T#empty? .310000 0.000000 0.310000 ( .317207) >> Q#clear 0.590000 0.000000 0.590000 ( .586336) >> T#clear 0.450000 0.000000 0.450000 ( .450514) >> Q#size .160000 0.000000 0.160000 ( .162851) >> T#size .310000 0.000000 0.310000 ( .316331) >> Q#num_waiting 0.160000 0.010000 0.170000 ( .166712) >> T#num_waiting 0.310000 0.000000 0.310000 ( .315460) >> >> So, Ruby implementation seems faster for #empty?, #size and >> #num_waiting (and #clear), which are all methods with a simple call to >> an Array method. >> But C #push ~2 times faster, and #pop ~5 times faster (implementation >> is better in C). >> Knowing these are the most used operations, this is a good improvement. > > Awesome! ¨Βθαξλζοδοιξτθεσε® ¨ΒΝΟ ιτ§σ ζυτο δο τθισ λιξδ οζ χοςλ> then see how much better you made the world. > > ¨ΒττπΊ――ιθιηθζιφε®γον― > > -- > Aaron Patterson > http://tenderlovemaking.com/ >