aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Benchmarks/bigtable/erubis.rb
diff options
context:
space:
mode:
Diffstat (limited to 'src/Benchmarks/bigtable/erubis.rb')
-rw-r--r--src/Benchmarks/bigtable/erubis.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Benchmarks/bigtable/erubis.rb b/src/Benchmarks/bigtable/erubis.rb
new file mode 100644
index 0000000..9a1edf9
--- /dev/null
+++ b/src/Benchmarks/bigtable/erubis.rb
@@ -0,0 +1,31 @@
1# BigTable benchmark implemented in erubis
2#
3require 'erubis'
4require 'benchmark'
5
6table = (1 .. 1000).map do |_| (1 .. 10) end
7
8template = Erubis::Eruby.new <<-EOF
9<table>
10 <% table.each do |row| %>
11 <tr>
12 <% row.each do |value| %>
13 <td>
14 <%= value %>
15 </td>
16 <% end %>
17 </tr>
18 <% end %>
19</table>
20EOF
21
22number_runs = 100
23start_time = Time.now.to_f
24number_runs.times do
25 template.result(binding)
26end
27end_time = Time.now.to_f
28
29# start_time and end_time are both in seconds now
30ms = (end_time - start_time) * 1000 / number_runs
31puts "\"Erubis\", #{ms}"