Skip to content

Commit

Permalink
Fix <=, ==, >= comparisons to avoid trivial object identity comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 10, 2011
1 parent 4e68d7a commit aaf7cc8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions benchmark/core/time/bench_comparable.rb
Expand Up @@ -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!

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit aaf7cc8

Please sign in to comment.