Skip to content

Commit

Permalink
add sort ascending with block
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Remes committed Feb 13, 2012
1 parent f1907ab commit 6737366
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions benchmark/core/array/bench_sort.rb
Expand Up @@ -34,6 +34,23 @@ def make_nested(kind)
end
end

x.report "sort strings ascending with block" do |times|
i = 0
while i < times
string_array.sort { |a,b| a <=> b }
i += 1
end
end

x.report "array sort! strings ascending with block" do |times|
i = 0
while i < times
array2 = string_array.dup
array2.sort! { |a,b| a <=> b }
i += 1
end
end

x.report "sort strings descending with block" do |times|
i = 0
while i < times
Expand Down Expand Up @@ -68,6 +85,23 @@ def make_nested(kind)
end
end

x.report "sort numbers ascending with block" do |times|
i = 0
while i < times
fixnum_array.sort { |a,b| a <=> b }
i += 1
end
end

x.report "array sort! numbers ascending with block" do |times|
i = 0
while i < times
array2 = fixnum_array.dup
array2.sort! { |a,b| a <=> b }
i += 1
end
end

x.report "sort numbers descending with block" do |times|
i = 0
while i < times
Expand Down Expand Up @@ -102,6 +136,23 @@ def make_nested(kind)
end
end

x.report "sort time ascending with block" do |times|
i = 0
while i < times
time_array.sort { |a,b| a <=> b }
i += 1
end
end

x.report "array sort! time ascending with block" do |times|
i = 0
while i < times
array2 = time_array.dup
array2.sort! { |a,b| a <=> b }
i += 1
end
end

x.report "sort time descending with block" do |times|
i = 0
while i < times
Expand Down

0 comments on commit 6737366

Please sign in to comment.