Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2884 Bytes
- Properties:
- Property svn:executable is set to *
1 | #!/usr/bin/env ruby |
2 | |
3 | times = (ARGV.first || 1000).to_i |
4 | |
5 | if times == 0 # Invalid parameter |
6 | puts <<END |
7 | ruby #$0 [times=1000] |
8 | Benchmark Haml against various other templating languages and Sass |
9 | on its own. |
10 | END |
11 | exit 1 |
12 | end |
13 | |
14 | require File.dirname(__FILE__) + '/../lib/haml' |
15 | require File.dirname(__FILE__) + '/linked_rails' |
16 | %w[sass rubygems erb erubis markaby active_support action_controller |
17 | action_view action_pack haml/template rbench].each {|dep| require(dep)} |
18 | |
19 | def view |
20 | unless Haml::Util.has?(:instance_method, ActionView::Base, :finder) |
21 | return ActionView::Base.new(File.dirname(__FILE__), {}) |
22 | end |
23 | |
24 | # Rails >=2.1.0 |
25 | base = ActionView::Base.new |
26 | base.finder.append_view_path(File.dirname(__FILE__)) |
27 | base |
28 | end |
29 | |
30 | def render(view, file) |
31 | view.render :file => file |
32 | end |
33 | |
34 | RBench.run(times) do |
35 | column :haml, :title => "Haml" |
36 | column :haml_ugly, :title => "Haml :ugly" |
37 | column :erb, :title => "ERB" |
38 | column :erubis, :title => "Erubis" |
39 | |
40 | template_name = 'standard' |
41 | directory = File.dirname(__FILE__) + '/haml' |
42 | haml_template = File.read("#{directory}/templates/#{template_name}.haml") |
43 | erb_template = File.read("#{directory}/rhtml/#{template_name}.rhtml") |
44 | markaby_template = File.read("#{directory}/markaby/#{template_name}.mab") |
45 | |
46 | report "Cached" do |
47 | obj = Object.new |
48 | |
49 | Haml::Engine.new(haml_template).def_method(obj, :haml) |
50 | Haml::Engine.new(haml_template, :ugly => true).def_method(obj, :haml_ugly) |
51 | Erubis::Eruby.new(erb_template).def_method(obj, :erubis) |
52 | obj.instance_eval("def erb; #{ERB.new(erb_template, nil, '-').src}; end") |
53 | |
54 | haml { obj.haml } |
55 | haml_ugly { obj.haml_ugly } |
56 | erb { obj.erb } |
57 | erubis { obj.erubis } |
58 | end |
59 | |
60 | report "ActionView" do |
61 | @base = view |
62 | |
63 | @base.unmemoize_all |
64 | Haml::Template.options[:ugly] = false |
65 | # To cache the template |
66 | render @base, 'haml/templates/standard' |
67 | render @base, 'haml/rhtml/standard' |
68 | |
69 | haml { render @base, 'haml/templates/standard' } |
70 | erb { render @base, 'haml/rhtml/standard' } |
71 | |
72 | Haml::Template.options[:ugly] = true |
73 | render @base, 'haml/templates/standard_ugly' |
74 | haml_ugly { render @base, 'haml/templates/standard_ugly' } |
75 | end |
76 | |
77 | report "ActionView with deep partials" do |
78 | @base = view |
79 | |
80 | @base.unmemoize_all |
81 | Haml::Template.options[:ugly] = false |
82 | # To cache the template |
83 | render @base, 'haml/templates/action_view' |
84 | render @base, 'haml/rhtml/action_view' |
85 | |
86 | haml { render @base, 'haml/templates/action_view' } |
87 | erb { render @base, 'haml/rhtml/action_view' } |
88 | |
89 | Haml::Template.options[:ugly] = true |
90 | render @base, 'haml/templates/action_view_ugly' |
91 | haml_ugly { render @base, 'haml/templates/action_view_ugly' } |
92 | end |
93 | end |
94 | |
95 | RBench.run(times) do |
96 | sass_template = File.read("#{File.dirname(__FILE__)}/sass/templates/complex.sass") |
97 | |
98 | report("Sass") { Sass::Engine.new(sass_template).render } |
99 | end |