--VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 total real > Queue: 100 0.380000 0.020000 0.400000 ( 0.390914) > Queue: 1000 3.750000 0.130000 3.880000 ( 3.934827) > Queue: 10000 37.270000 1.340000 38.610000 ( 39.136691) > Thread::Queue: 100 0.130000 0.000000 0.130000 ( 0.132765) > Thread::Queue: 1000 1.260000 0.060000 1.320000 ( 1.353208) > Thread::Queue: 10000 12.490000 0.580000 13.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 total real > Q#push 0.810000 0.000000 0.810000 ( 0.818967) > T#push 0.350000 0.000000 0.350000 ( 0.369173) > Q#pop 1.710000 0.010000 1.720000 ( 1.719467) > T#pop 0.340000 0.000000 0.340000 ( 0.344720) > Q#empty? 0.200000 0.000000 0.200000 ( 0.202756) > T#empty? 0.310000 0.000000 0.310000 ( 0.317207) > Q#clear 0.590000 0.000000 0.590000 ( 0.586336) > T#clear 0.450000 0.000000 0.450000 ( 0.450514) > Q#size 0.160000 0.000000 0.160000 ( 0.162851) > T#size 0.310000 0.000000 0.310000 ( 0.316331) > Q#num_waiting 0.160000 0.010000 0.170000 ( 0.166712) > T#num_waiting 0.310000 0.000000 0.310000 ( 0.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! Thanks for doing these. IMO it's fun to do this kind of work, then see how much better you made the world. http://ihighfive.com/ -- Aaron Patterson http://tenderlovemaking.com/ --VS++wcV0S1rZb1Fb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iQEcBAEBAgAGBQJMQzY9AAoJEJUxcLy0/6/GuPAH/1XUWHRiEHBpZVV54k53zyRD ShLAVfikLz4OvJV894KXcx/fB4BHXoAJyXakusQVeV4Dy0QE39CIImzV+L4eO7TT KllPYS2BOTeQYTfRfMPit53l0Hn+ePzZHACYB28CuDD899cfliNL37zyhYt7liL4 xG5Jtpa7n5Mi3X/8i021kHX0K/aPpKs9vX2+KuleYQZvcCou/TogFNmuwytrGER3 Zr6EJiGIu0P2bINQqV7VXjEJnqFpbbpvbRjlgdlcxK9AAK5vQ8gfxdJOgHpHiZ2a 0nAnjRoGcf0HtHoQjgZKd3hk9aMSB8ZOGdWUj7tYeWX2O04Tje48fYVrp1qSI5I kq -----END PGP SIGNATURE----- --VS++wcV0S1rZb1Fb--