Permalink
Browse files

Fix <=, ==, >= comparisons to avoid trivial object identity comparisons.

  • Loading branch information...
1 parent 4e68d7a commit aaf7cc806a0d8b73c7a8e1601a69ccd960aa5033 @headius headius committed Apr 1, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 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,23 +25,23 @@
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
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
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,23 +65,23 @@
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
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
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

0 comments on commit aaf7cc8

Please sign in to comment.