Skip to content

Instantly share code, notes, and snippets.

@madx
Created June 11, 2009 13:15
Show Gist options
  • Save madx/127889 to your computer and use it in GitHub Desktop.
Save madx/127889 to your computer and use it in GitHub Desktop.
require 'rubygems'
require File.join(File.dirname(__FILE__), 'lib', 'xup')
require 'redcloth'
require 'haml'
require 'markaby'
require 'benchmark'
Xup.load :xml
n = 10_000
Benchmark.bm(10) do |x|
x.report("xup:") do
for i in 0..n
xc = Xup::Context.new
xc.instance_eval {
use :XML
tag! :para, "foo"
tag! :ul do
tag! :li, 'one'
tag! :li, 'two'
tag! :li, 'three'
end
}
xc.buffer
end
end
x.report("xup (str):") do
for i in 0..n
xc = Xup::Context.new
xc.instance_eval &lambda { eval <<-eof
use :XML
tag! :para, "foo"
tag! :ul do
tag! :li, 'one'
tag! :li, 'two'
tag! :li, 'three'
end
eof
}
xc.buffer
end
end
x.report("markaby:") do
for i in 0..n
Markaby::Builder.new {
p "foo"
ul {
li "one"
li "two"
li "three"
}
}.streams.first.first
end
end
x.report("textile:") do
for i in 0..n
RedCloth.new("p. foo\n\n* one\n* two\n* three").to_html
end
end
x.report("haml:") do
for i in 0..n
Haml::Engine.new("%p foo\n%ul\n %li one\n %li two\n %li three").to_html
end
end
end
user system total real
xup: 1.990000 0.050000 2.040000 ( 2.108340)
xup (str): 2.440000 0.090000 2.530000 ( 2.538592)
markaby: 8.680000 0.220000 8.900000 ( 8.992089)
textile: 9.000000 0.880000 9.880000 ( 9.989805)
haml: 8.770000 0.350000 9.120000 ( 9.237272)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment