From: Sean O'Halpin [mailto:sean.ohalpin / gmail.com]=20
# $ ruby bm-duplicates.rb
# ----------------------------------------
# no duplicates
# ----------------------------------------
#                     user     system      total        real
# duplicates_1    2.200000   0.010000   2.210000 (  2.215057)
# duplicates_2    5.820000   0.000000   5.820000 (  5.812414)
# duplicates_3    6.580000   0.010000   6.590000 (  6.586708)
# ----------------------------------------
# duplicates
# ----------------------------------------
#                     user     system      total        real
# duplicates_1    1.560000   0.000000   1.560000 (  1.562587)
# duplicates_2    2.660000   0.000000   2.660000 (  2.665301)
# duplicates_3    2.590000   0.000000   2.590000 (  2.595189)

i just tested this using ruby1.9 on a p4 box running windowsxp. i =
included ruby's group_by and got surprising results.

C:\ruby1.9\bin>diff test-old.rb test.rb
19a20,24
> #1.9's group_by
> def duplicates_4(array)
>   array.group_by{|e|e}.select{|_,k| k.size>1}.keys
> end
>
26c31
<   Benchmark.bm(methods.map{ |x| x.to_s.length}.max + 2) do |x|
---
>   Benchmark.bmbm(methods.map{ |x| x.to_s.length}.max + 2) do |x|
34c39
< array =3D File.read('/etc/dictionaries-common/words').split(/\n/)
---
> array =3D File.read('american-english').split(/\n/)
38c43
< :duplicates_3], array)
---
> :duplicates_3,:duplicates_4], array)
43c48
< :duplicates_3], array)
---
> :duplicates_3,:duplicates_4], array)

C:\ruby1.9\bin>


C:\ruby1.9\bin>ruby test.rb
----------------------------------------
no duplicates
----------------------------------------
Rehearsal -------------------------------------------------
duplicates_1    7.609000   0.094000   7.703000 (  7.984000)
duplicates_2   10.438000   0.109000  10.547000 ( 11.608000)
duplicates_3   14.609000   0.219000  14.828000 ( 14.874000)
duplicates_4   11.422000   0.141000  11.563000 ( 14.201000)
--------------------------------------- total: 44.641000sec

                    user     system      total        real
duplicates_1    7.219000   0.125000   7.344000 (  8.109000)
duplicates_2    9.844000   0.078000   9.922000 ( 10.374000)
duplicates_3   14.391000   0.172000  14.563000 ( 18.498000)
duplicates_4   11.172000   0.172000  11.344000 ( 12.998000)
----------------------------------------
duplicates
----------------------------------------
Rehearsal -------------------------------------------------
duplicates_1    3.375000   0.000000   3.375000 (  3.765000)
duplicates_2    3.218000   0.000000   3.218000 (  3.828000)
duplicates_3    3.250000   0.000000   3.250000 (  3.672000)
duplicates_4    2.032000   0.047000   2.079000 (  2.077000)
--------------------------------------- total: 11.922000sec

                    user     system      total        real
duplicates_1    3.375000   0.000000   3.375000 (  3.437000)
duplicates_2    3.188000   0.000000   3.188000 (  3.218000)
duplicates_3    3.219000   0.015000   3.234000 (  3.281000)
duplicates_4    1.844000   0.000000   1.844000 (  1.859000)

C:\ruby1.9\bin>

kind regards -botp