From: David Alan Black Date: 2000-12-28T19:59:24+09:00 Subject: [ruby-talk:8165] Re: speedup of anagram finder On Thu, 28 Dec 2000, Joseph McDonald wrote: > > > > > Next! > > > > That's gotta be me. Well, I had a feeling that the > bottleneck was in the call to split (why it's a bottleneck > I don't know). So short of writing a "sort" routine for > String (which would probably make this thing fly), I tried > the only thing I knew of to get around calling split. > That was to call each_byte. It sure made a difference > (don't ask me why, I don't know). [...] > % head -20000 /usr/share/dict/words | ./anagrams2.rb > user system total real > keys 5.148438 0.023438 5.171875 ( 5.219981) > each_byte 1.835938 0.015625 1.851562 ( 1.862386) Hmmmm.... I don't get anything like that kind of difference between Dave's and yours -- or mine, for that matter. Here are some figures for the three of them. Notice that the one that runs first gets measure too long. user system total real david 5.950000 0.060000 6.010000 ( 6.002994) dave 5.200000 0.010000 5.210000 ( 5.219068) joe 5.270000 0.060000 5.330000 ( 5.677909) david 5.210000 0.000000 5.210000 ( 5.206700) dave 5.240000 0.000000 5.240000 ( 5.232835) joe 5.240000 0.000000 5.240000 ( 5.237969) Another run, with joe first: user system total real joe 5.620000 0.070000 5.690000 ( 5.706385) david 4.930000 0.000000 4.930000 ( 4.937458) dave 4.950000 0.000000 4.950000 ( 4.955197) david 4.940000 0.000000 4.940000 ( 4.945525) dave 4.950000 0.000000 4.950000 ( 4.954456) joe 5.000000 0.000000 5.000000 ( 4.991997) So there seems to be some order dependency, at least for the first one. This was happening big time when I measured mine and gotoken's. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav