1prelude: |
2  require 'erb'
3
4  data = <<erb
5  <html>
6    <head> <%= title %> </head>
7    <body>
8      <h1> <%= title %> </h1>
9      <p>
10        <%= content %>
11      </p>
12    </body>
13  </html>
14  erb
15
16  title = "hello world!"
17  content = "hello world!\n" * 10
18
19  src = "def self.render(title, content); #{ERB.new(data).src}; end"
20  mod = Module.new
21  mod.instance_eval(src, "(ERB)")
22benchmark:
23  erb_render: mod.render(title, content)
24loop_count: 1500000
25