Last active
August 29, 2015 14:08
-
-
Save bryanp/75c8e82f7d2a15d0783f to your computer and use it in GitHub Desktop.
StringDoc Benchmark (Pakyow v0.9 + Ruby 2.1.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user system total real | |
rendering (Pakyow::Presenter::StringDoc) | |
0.300000 0.000000 0.300000 ( 0.314247) | |
rendering (Pakyow::Presenter::NokogiriDoc) | |
0.390000 0.000000 0.390000 ( 0.389738) | |
finding scope (Pakyow::Presenter::StringDoc) | |
1.400000 0.020000 1.420000 ( 1.418042) | |
finding scope (Pakyow::Presenter::NokogiriDoc) | |
4.270000 0.020000 4.290000 ( 4.346917) | |
applying data (Pakyow::Presenter::StringDoc) | |
7.640000 0.020000 7.660000 ( 7.701998) | |
applying data (Pakyow::Presenter::NokogiriDoc) | |
30.140000 0.140000 30.280000 ( 31.020088) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'pakyow' | |
iterations = 10_000 | |
html = File.open('./view.html').read | |
s_view = Pakyow::Presenter::View.from_doc(Pakyow::Presenter::StringDoc.new(html)) | |
n_view = Pakyow::Presenter::View.from_doc(Pakyow::Presenter::NokogiriDoc.new(html)) | |
views = [s_view, n_view] | |
data = [ { title: 'one' }, { title: 'two' }, { title: 'three' }] | |
Benchmark.bm do |bm| | |
views.each do |view| | |
puts | |
puts "rendering (#{view.doc.class})" | |
bm.report do | |
iterations.times { view.to_html } | |
end | |
end | |
views.each do |view| | |
puts | |
puts "finding scope (#{view.doc.class})" | |
bm.report do | |
iterations.times { view.scope(:post) } | |
end | |
end | |
views.each do |view| | |
puts | |
puts "applying data (#{view.doc.class})" | |
bm.report do | |
iterations.times { view.scope(:post).apply(data) } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-scope="post"> | |
<h1 data-prop="title">title</h1> | |
<div> | |
<p data-prop="body">body</p> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment