Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 1902 Bytes
1 | require File.dirname(__FILE__) + '/../lib/haml/template' |
2 | require 'rubygems' |
3 | require 'active_support' |
4 | require 'action_view' |
5 | require 'benchmark' |
6 | require 'stringio' |
7 | |
8 | module Haml |
9 | class Benchmarker |
10 | |
11 | # Creates a new benchmarker that looks for templates in the base |
12 | # directory. |
13 | def initialize(base = File.dirname(__FILE__)) |
14 | ActionView::Base.register_template_handler("haml", Haml::Template) |
15 | unless base.class == ActionView::Base |
16 | @base = ActionView::Base.new(base) |
17 | else |
18 | @base = base |
19 | end |
20 | end |
21 | |
22 | # Benchmarks HAML against ERb. If <tt>template_name</tt> is specified, |
23 | # looks for a haml template in ./templates and an rhtml template in |
24 | # ./rhtml with the name <tt>template_name</tt>. Otherwise, uses |
25 | # <tt>haml_template</tt> and <tt>rhtml_template</tt> as the location of |
26 | # the templates. |
27 | # |
28 | # Returns the results of the benchmarking as a string. |
29 | # |
30 | # :call-seq: |
31 | # benchmark(runs = 100, template_name = 'standard') |
32 | # benchmark(runs = 100, haml_template, rhtml_template) |
33 | # |
34 | def benchmark(runs = 100, template_name = 'standard', other_template = nil) |
35 | if other_template.nil? |
36 | haml_template = "templates/#{template_name}" |
37 | rhtml_template = "rhtml/#{template_name}" |
38 | else |
39 | haml_template = template_name |
40 | rhtml_template = other_template |
41 | end |
42 | |
43 | old_stdout = $stdout |
44 | $stdout = StringIO.new |
45 | |
46 | times = Benchmark.bmbm do |b| |
47 | b.report("haml:") { runs.times { @base.render haml_template } } |
48 | b.report("erb:") { runs.times { @base.render rhtml_template } } |
49 | end |
50 | |
51 | #puts times.inspect |
52 | ratio = sprintf("%g", times[0].to_a[5] / times[1].to_a[5]) |
53 | puts "Haml/ERB: " + ratio |
54 | |
55 | $stdout.pos = 0 |
56 | to_return = $stdout.read |
57 | $stdout = old_stdout |
58 | |
59 | to_return |
60 | end |
61 | end |
62 | end |