Skip to content

Commit

Permalink
Fixed String#insert benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
hosiawak committed Jun 21, 2011
1 parent ef76cde commit 9d9daba
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions benchmark/core/string/bench_insert.rb
Expand Up @@ -4,31 +4,30 @@

Benchmark.ips do |x|

short_sentence = $short_sentence.dup
start = 0
index = 50
insert = "abc"

x.report "insert(#{start},'#{insert}')" do |times|
i = 0
while i < times
short_sentence.insert(start, insert)
$short_sentence.dup.insert(start, insert)
i += 1
end
end

x.report "insert(-1, '#{insert}')" do |times|
i = 0
while i < times
short_sentence.insert(-1, insert)
$short_sentence.dup.insert(-1, insert)
i += 1
end
end

x.report "insert(#{index}, '#{insert}')" do |times|
i = 0
while i < times
short_sentence.insert(index, insert)
$short_sentence.dup.insert(index, insert)
i += 1
end
end
Expand Down

0 comments on commit 9d9daba

Please sign in to comment.