diff options
Diffstat (limited to 'src/Benchmarks/bigtable/erubis.rb')
-rw-r--r-- | src/Benchmarks/bigtable/erubis.rb | 31 |
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 | # | ||
3 | require 'erubis' | ||
4 | require 'benchmark' | ||
5 | |||
6 | table = (1 .. 1000).map do |_| (1 .. 10) end | ||
7 | |||
8 | template = 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> | ||
20 | EOF | ||
21 | |||
22 | number_runs = 100 | ||
23 | start_time = Time.now.to_f | ||
24 | number_runs.times do | ||
25 | template.result(binding) | ||
26 | end | ||
27 | end_time = Time.now.to_f | ||
28 | |||
29 | # start_time and end_time are both in seconds now | ||
30 | ms = (end_time - start_time) * 1000 / number_runs | ||
31 | puts "\"Erubis\", #{ms}" | ||