From aaf7cc806a0d8b73c7a8e1601a69ccd960aa5033 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 31 Mar 2011 23:59:27 -0500 Subject: [PATCH] Fix <=, ==, >= comparisons to avoid trivial object identity comparisons. --- benchmark/core/time/bench_comparable.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/benchmark/core/time/bench_comparable.rb b/benchmark/core/time/bench_comparable.rb index d722728aa1..546d832b83 100644 --- a/benchmark/core/time/bench_comparable.rb +++ b/benchmark/core/time/bench_comparable.rb @@ -7,8 +7,10 @@ temp = $small_time_float_array.sort fixnum_time = Time.at(temp[0].to_i) + fixnum_time2 = Time.at(temp[0].to_i) float_time = temp[0] + float_time2 = temp[0] x.compare! @@ -23,7 +25,7 @@ x.report "time <= time, (fixnum <=> fixnum)" do |times| i = 0 while i < times - fixnum_time <= fixnum_time + fixnum_time <= fixnum_time2 i += 1 end end @@ -31,7 +33,7 @@ x.report "time == time, (fixnum <=> fixnum)" do |times| i = 0 while i < times - fixnum_time == fixnum_time + fixnum_time == fixnum_time2 i += 1 end end @@ -39,7 +41,7 @@ x.report "time >= time, (fixnum <=> fixnum)" do |times| i = 0 while i < times - fixnum_time >= fixnum_time + fixnum_time >= fixnum_time2 i += 1 end end @@ -63,7 +65,7 @@ x.report "time <= time, (float <=> float)" do |times| i = 0 while i < times - float_time <= float_time + float_time <= float_time2 i += 1 end end @@ -71,7 +73,7 @@ x.report "time == time, (float <=> float)" do |times| i = 0 while i < times - float_time == float_time + float_time == float_time2 i += 1 end end @@ -79,7 +81,7 @@ x.report "time >= time, (float <=> float)" do |times| i = 0 while i < times - float_time >= float_time + float_time >= float_time2 i += 1 end end