Sha256: e99f4798799c7a53e13b79268f24c50e5e98d5acc2461ce9ee2d57b7c6f4da0b

Contents?: true

Size: 865 Bytes

Versions: 7

Compression:

Stored size: 865 Bytes

Contents

# encoding: utf-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'

require 'action_view'
require 'escape_utils'

class ActionPackBench
  extend ActionView::Helpers::JavaScriptHelper
end

times = 100
url = "http://ajax.googleapis.com/ajax/libs/dojo/1.4.3/dojo/dojo.xd.js.uncompressed.js"
javascript = `curl -s #{url}`
puts "Escaping #{javascript.bytesize} bytes of javascript #{times} times, from #{url}"

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

  x.report do
    puts "EscapeUtils.escape_javascript"
    times.times do
      EscapeUtils.escape_javascript(javascript)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
escape_utils-0.2.1 benchmark/javascript_escape.rb
escape_utils-0.2.0 benchmark/javascript_escape.rb
escape_utils-0.1.9 benchmark/javascript_escape.rb
escape_utils-0.1.8 benchmark/javascript_escape.rb
escape_utils-0.1.7 benchmark/javascript_escape.rb
escape_utils-0.1.6 benchmark/javascript_escape.rb
escape_utils-0.1.5 benchmark/javascript_escape.rb