Skip to content

Commit

Permalink
update usage of Benchmark#report
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmario committed Feb 21, 2011
1 parent 5bc0d83 commit 2a4620e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 44 deletions.
18 changes: 6 additions & 12 deletions benchmark/html_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,37 @@ module HamlBench
puts "Escaping #{html.bytesize} bytes of html #{times} times, from #{url}"

Benchmark.bmbm do |x|
x.report do
puts "Rack::Utils.escape_html"
x.report "Rack::Utils.escape_html" do
times.times do
Rack::Utils.escape_html(html)
end
end

x.report do
puts "Haml::Helpers.html_escape"
x.report "Haml::Helpers.html_escape" do
times.times do
HamlBench.html_escape(html)
end
end

x.report do
puts "ERB::Util.html_escape"
x.report "ERB::Util.html_escape" do
times.times do
ERB::Util.html_escape(html)
end
end

x.report do
puts "CGI.escapeHTML"
x.report "CGI.escapeHTML" do
times.times do
CGI.escapeHTML(html)
end
end

x.report do
puts "fast_xs_extra#fast_xs_html"
x.report "fast_xs_extra#fast_xs_html" do
times.times do
html.fast_xs_html
end
end

x.report do
puts "EscapeUtils.escape_html"
x.report "EscapeUtils.escape_html" do
times.times do
EscapeUtils.escape_html(html)
end
Expand Down
6 changes: 2 additions & 4 deletions benchmark/html_unescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ module HamlBench
puts "Unescaping #{escaped_html.bytesize} bytes of escaped html #{times} times, from #{url}"

Benchmark.bmbm do |x|
x.report do
puts "CGI.unescapeHTML"
x.report "CGI.unescapeHTML" do
times.times do
CGI.unescapeHTML(escaped_html)
end
end

x.report do
puts "EscapeUtils.unescape_html"
x.report "EscapeUtils.unescape_html" do
times.times do
EscapeUtils.unescape_html(escaped_html)
end
Expand Down
6 changes: 2 additions & 4 deletions benchmark/javascript_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ class ActionPackBench
puts "Escaping #{javascript.bytesize} bytes of javascript #{times} times, from #{url}"

Benchmark.bmbm do |x|
x.report do
puts "ActionView::Helpers::JavaScriptHelper#escape_javascript"
x.report "ActionView::Helpers::JavaScriptHelper#escape_javascript" do
times.times do
ActionPackBench.escape_javascript(javascript)
end
end

x.report do
puts "EscapeUtils.escape_javascript"
x.report "EscapeUtils.escape_javascript" do
times.times do
EscapeUtils.escape_javascript(javascript)
end
Expand Down
3 changes: 1 addition & 2 deletions benchmark/javascript_unescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
puts "Escaping #{escaped_javascript.bytesize} bytes of javascript #{times} times, from #{url}"

Benchmark.bmbm do |x|
x.report do
puts "EscapeUtils.escape_javascript"
x.report "EscapeUtils.escape_javascript" do
times.times do
EscapeUtils.unescape_javascript(escaped_javascript)
end
Expand Down
18 changes: 6 additions & 12 deletions benchmark/url_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,37 @@
puts "Escaping a #{url.bytesize} byte URL #{times} times"

Benchmark.bmbm do |x|
x.report do
puts "ERB::Util.url_encode"
x.report "ERB::Util.url_encode" do
times.times do
ERB::Util.url_encode(url)
end
end

x.report do
puts "Rack::Utils.escape"
x.report "Rack::Utils.escape" do
times.times do
Rack::Utils.escape(url)
end
end

x.report do
puts "CGI.escape"
x.report "CGI.escape" do
times.times do
CGI.escape(url)
end
end

x.report do
puts "URLEscape#escape"
x.report "URLEscape#escape" do
times.times do
URLEscape.escape(url)
end
end

x.report do
puts "fast_xs_extra#fast_xs_url"
x.report "fast_xs_extra#fast_xs_url" do
times.times do
url.fast_xs_url
end
end

x.report do
puts "EscapeUtils.escape_url"
x.report "EscapeUtils.escape_url" do
times.times do
EscapeUtils.escape_url(url)
end
Expand Down
15 changes: 5 additions & 10 deletions benchmark/url_unescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,31 @@
puts "Escaping a #{url.bytesize} byte URL #{times} times"

Benchmark.bmbm do |x|
x.report do
puts "Rack::Utils.unescape"
x.report "Rack::Utils.unescape" do
times.times do
Rack::Utils.unescape(escaped_url)
end
end

x.report do
puts "CGI.unescape"
x.report "CGI.unescape" do
times.times do
CGI.unescape(escaped_url)
end
end

x.report do
puts "URLEscape#unescape"
x.report "URLEscape#unescape" do
times.times do
URLEscape.unescape(escaped_url)
end
end

x.report do
puts "fast_xs_extra#fast_uxs_cgi"
x.report "fast_xs_extra#fast_uxs_cgi" do
times.times do
url.fast_uxs_cgi
end
end

x.report do
puts "EscapeUtils.unescape_url"
x.report "EscapeUtils.unescape_url" do
times.times do
EscapeUtils.unescape_url(escaped_url)
end
Expand Down

0 comments on commit 2a4620e

Please sign in to comment.