Sha256: 455fcd11783612d467286a218784aec2a3e6b7477330e84600423963cc44a380

Contents?: true

Size: 845 Bytes

Versions: 19

Compression:

Stored size: 845 Bytes

Contents

require 'benchmark/driver'
require 'erb'
require 'erubi'
require 'erubis'

data = DATA.read

mod = Module.new
mod.instance_eval("def self.erb(title, content); #{ERB.new(data).src}; end", "(ERB)")
mod.instance_eval("def self.erubis(title, content); #{Erubi::Engine.new(data).src}; end", "(Erubi)")
mod.instance_eval("def self.erubi(title, content); #{Erubis::Eruby.new(data).src}; end", "(Erubis)")

title = "hello world!"
content = "hello world!\n" * 10

Benchmark.driver do |x|
  x.report("ERB #{RUBY_VERSION}")       { mod.erb(title, content) }
  x.report("Erubis #{Erubis::VERSION}") { mod.erubis(title, content) }
  x.report("Erubi #{Erubi::VERSION}")   { mod.erubi(title, content) }
  x.compare!
end

__END__

<html>
  <head> <%= title %> </head>
  <body>
    <h1> <%= title %> </h1>
    <p>
      <%= content %>
    </p>
  </body>
</html>

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
benchmark_driver-0.8.6 examples/call_erb.rb
benchmark_driver-0.8.5 examples/call_erb.rb
benchmark_driver-0.8.4 examples/call_erb.rb
benchmark_driver-0.8.3 examples/call_erb.rb
benchmark_driver-0.8.2 examples/call_erb.rb
benchmark_driver-0.8.1 examples/call_erb.rb
benchmark_driver-0.8.0 examples/call_erb.rb
benchmark_driver-0.7.2 examples/call_erb.rb
benchmark_driver-0.7.1 examples/call_erb.rb
benchmark_driver-0.7.0 examples/call_erb.rb
benchmark_driver-0.6.2 examples/call_erb.rb
benchmark_driver-0.5.1 examples/call_erb.rb
benchmark_driver-0.5.0 examples/call_erb.rb
benchmark_driver-0.4.5 examples/call_erb.rb
benchmark_driver-0.4.4 examples/call_erb.rb
benchmark_driver-0.4.3 examples/call_erb.rb
benchmark_driver-0.4.2 examples/call_erb.rb
benchmark_driver-0.4.1 examples/call_erb.rb
benchmark_driver-0.4.0 examples/call_erb.rb