aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Benchmarks/bigtable/erubis.rb
blob: 9a1edf9ed4de5172f1fbcc92ddfbb40a01439a98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# BigTable benchmark implemented in erubis
#
require 'erubis'
require 'benchmark'

table = (1 .. 1000).map do |_| (1 .. 10) end

template = Erubis::Eruby.new <<-EOF
<table>
  <% table.each do |row| %>
    <tr>
      <% row.each do |value| %>
        <td>
            <%= value %>
        </td>
      <% end %>
    </tr>
  <% end %>
</table>
EOF

number_runs = 100
start_time = Time.now.to_f
number_runs.times do
    template.result(binding)
end
end_time = Time.now.to_f

# start_time and end_time are both in seconds now
ms = (end_time - start_time) * 1000 / number_runs
puts "\"Erubis\", #{ms}"