Hello Eric,

I'm confused by the code below. First, it uses Math::PI with the 'tau' 
option, and Math::TAU with the '2pi' option. Second, even when using 
Math::TAU, it includes a multiplication by 2.

Regards,   Martin.

On 2013/02/27 14:08, drbrain (Eric Hodel) wrote:

> Benchmarks:
>
>    $ cat bm.rb
>    require 'benchmark'
>
>    module Math
>      TAU = 2*Math::PI
>    end
>
>    range = Float::EPSILON..10.0
>
>    N = Integer ARGV.shift
>
>    case ARGV.shift
>    when 'tau' then
>      puts Benchmark.measure {
>        N.times do
>          2 * Math::PI * rand(range)
>        end
>      }.real
>    when '2pi' then
>      puts Benchmark.measure {
>        N.times do
>          2 * Math::TAU * rand(range)
>        end
>      }.real
>    else
>      abort "#{$0} N tau|2pi"
>    end