------art_72180_6400778.1171316329227
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 2/12/07, James Edward Gray II <james / grayproductions.net> wrote:
>
> On Feb 12, 2007, at 12:26 PM, Robert Dober wrote:
>
> > 521/21 > cat bench.rb
> >  require 'benchmark'
> >
> >    array  1..100000).map { rand * (ARGV.first||1_000_000).to_f }
> >
> > def phrogz quiz
> >  i,fiz.to_s.split('.'); i.gsub(/(\d)(?
{3}+$)/,'\\1,') + (f ?
{3}+$)/,'\\1,') + (f ?
> > ('.'+f) : '')
> > end
> > def james quiz
> >  quiz.to_s.reverse.gsub(/(\d\d\d)(?
)(?!\d*\.)/,"\\1,").reverse
)(?!\d*\.)/,"\\1,").reverse
> > end
> >
> >
> >    Benchmark.bmbm do |x|
> >      x.report("Phrogz") {array.map{ |e| phrogz(e) }}
> >      x.report("James")  {array.map{ |e| james(e) }}
> >    end
>
> How does this code work?  You pass arguments to methods we don't
> see.  The ones we do see don't even accept arguments.
>
> The results look right though:


I am a magician ;)
well maybe not, I do not really understand, I have had the impression before
that gmail does not work correctly all the time
nahh it's probably just me I just steal any second on the list from my work
as sysadmin and IP/Sec officer and maybe I should not :(

Nevertheless, I can see the complete code with the two  methods in your
reply to the post!
Anyway here goes the definition of the two methods(again).

def phrogz quiz
>  i,fiz.to_s.split('.'); i.gsub(/(\d)(?
{3}+$)/,'\\1,') + (f ?
{3}+$)/,'\\1,') + (f ?
> ('.'+f) : '')
> end
> def james quiz
>  quiz.to_s.reverse.gsub(/(\d\d\d)(?
)(?!\d*\.)/,"\
)(?!\d*\.)/,"\
>
> \1,").reverse
> > end



and again?

#!/usr/bin/env ruby -w
>
> require "benchmark"
>
> def phrogz(num)
>    i,fm.to_s.split('.'); i.gsub(/(\d)(?
{3}+$)/,'\\1,') + (f ?
{3}+$)/,'\\1,') + (f ?
> ('.'+f) : '')
> end
>
> def james(num)
>    num.to_s.reverse.gsub(/(\d\d\d)(?
)(?!\d*\.)/,"\\1,").reverse
)(?!\d*\.)/,"\\1,").reverse
> end
>
> TESTS  rray.new(100_000) { rand(1_000_000) + 1.to_f / (rand(1_000)
> + 1) }
> Benchmark.bmbm do |results|
>    results.report("Phrogz:") { TESTS.each { |n| phrogz(n) } }
>    results.report("James:") { TESTS.each { |n| james(n) } }
> end
> # >> Rehearsal -------------------------------------------
> # >> Phrogz:   1.690000   0.010000   1.700000 (  1.700985)
> # >> James:    1.550000   0.010000   1.560000 (  1.557882)
> # >> ---------------------------------- total: 3.260000sec
> # >>
> # >>               user     system      total        real
> # >> Phrogz:   1.690000   0.010000   1.700000 (  1.703213)
> # >> James:    1.520000   0.000000   1.520000 (  1.528621)
>
> __END__
>
> James Edward Gray II
>
> Robert

I will change my signature soon, maybe it is its fault :)


-- 
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important
things.
-Anonymous

------art_72180_6400778.1171316329227--