Skip to content

Instantly share code, notes, and snippets.

@nahi
Created January 12, 2012 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/1598003 to your computer and use it in GitHub Desktop.
Save nahi/1598003 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'benchmark'
HEADER = <<__EOS__
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:blip="http://blip.tv/dtd/blip/1.0"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:amp="http://www.adobe.com/amp/1.0"
xmlns:dcterms="http://purl.org/dc/terms"
xmlns:gm="http://www.google.com/schemas/gm/1.1"
xmlns:mediaad="http://blip.tv/dtd/mediaad/1.0">
<channel>
<title>Recent Posts - Blip</title>
<link>http://blip.tv</link>
<description>Recent Posts - Blip - Blip</description>
<language>en-us</language>
<generator>http://blip.tv</generator>
<lastBuildDate>Tue, 10 Jan 2012 16:56:51 +0000</lastBuildDate>
<pubDate>Tue, 10 Jan 2012 16:56:51 +0000</pubDate>
__EOS__
ELEMENT = <<__EOS__
<item>
<guid isPermaLink="false">17992B2C-3BAC-11E1-9A3A-9F7355E7555A</guid>
<link>http://blip.tv/healthyvegan/my-healthy-food-list-to-stock-up-your-kitchen-5876335</link>
<title>My Healthy Food List To Stock Up Your Kitchen</title>
<blip:user>healthyvegan</blip:user>
<blip:userid>515315</blip:userid>
<blip:safeusername>healthyveganrecipes</blip:safeusername>
<blip:showpath>healthyvegan</blip:showpath>
<blip:show>healthyvegan</blip:show>
<blip:showpage>http://blip.tv/healthyvegan</blip:showpage>
<blip:picture>http://a.images.blip.tv/Healthyvegan-picture315.jpg</blip:picture>
<blip:posts_id>5876335</blip:posts_id>
<blip:item_id>5859343</blip:item_id>
<blip:item_type>file</blip:item_type>
<blip:contentRating>TV-UN</blip:contentRating>
<blip:rating>0.0</blip:rating>
<blip:datestamp>2012-01-10T16:56:51Z</blip:datestamp>
<blip:language>English</blip:language>
<blip:adChannel>Food/Drink</blip:adChannel>
<blip:recommendations>0</blip:recommendations>
<blip:recommendable>0</blip:recommendable>
<blip:core>0</blip:core>
<blip:channel_name>Food &amp; Drink</blip:channel_name>
<blip:adminRating>2</blip:adminRating>
<blip:runtime></blip:runtime>
<blip:embedLookup>AYLm1VMC</blip:embedLookup>
<blip:embedUrl type="application/x-shockwave-flash">http://blip.tv/play/AYLm1VMC</blip:embedUrl>
<wfw:commentRss>http://blip.tv/comments/?attached_to=post5876335&amp;skin=rss</wfw:commentRss>
<blip:thumbnail_src>notfound-episode.png</blip:thumbnail_src>
<blip:puredescription><![CDATA[Go to http://www.healthyeatingstartshere.com/food/healthy-food-list for the full article. A healthy food list is the first step on your way to success with a healthy eating plan. I put together my own healthy shopping list to help you stock your kitchen, especially if you&apos;re just starting out on a vegetarian or vegan diet plan... What&apos;s on your healthy food list? Let me know below. And check out http://www.healthyeatingstartshere.com for the free &apos;7 Secrets For Shaping Up Your Healthy Eating Habits&apos;.]]></blip:puredescription>
<blip:license>No license (All rights reserved)</blip:license>
<description><![CDATA[
<iframe src="http://blip.tv/play/AYLm1VMC.html?p=1" width="480" height="390" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#AYLm1VMC" style="display:none"></embed>
<br />
Go to http://www.healthyeatingstartshere.com/food/healthy-food-list for the full article. A healthy food list is the first step on your way to success with a healthy eating plan. I put together my own healthy shopping list to help you stock your kitchen, especially if you&apos;re just starting out on a vegetarian or vegan diet plan... What&apos;s on your healthy food list? Let me know below. And check out http://www.healthyeatingstartshere.com for the free &apos;7 Secrets For Shaping Up Your Healthy Eating Habits&apos;.
]]></description>
<comments>http://blip.tv/file/5859343</comments>
<category>Educational</category>
<category>healthy food list</category>
<category>healthy shopping list</category>
<category>list of healthy foods</category>
<category>vegan diet plan</category>
<category>healthy eating</category>
<category>healthy diet plan</category>
<pubDate>Tue, 10 Jan 2012 16:56:51 +0000</pubDate>
<enclosure length="138044693" type="video/vnd.objectvideo" url="http://blip.tv/file/get/Healthyvegan-MyHealthyFoodListToStockUpYourKitchen723.mp4"/>
<itunes:keywords>healthy food list, healthy shopping list, list of healthy foods, vegan diet plan, healthy eating, healthy diet plan</itunes:keywords>
<itunes:image>http://a.images.blip.tv/notfound-episode.png</itunes:image>
<media:keywords>healthy food list, healthy shopping list, list of healthy foods, vegan diet plan, healthy eating, healthy diet plan</media:keywords>
<media:group>
<media:content blip:role="Source" expression="full" fileSize="138044693" isDefault="true" type="video/mp4" url="http://blip.tv/file/get/Healthyvegan-MyHealthyFoodListToStockUpYourKitchen723.mp4"></media:content>
</media:group>
<media:player url="http://blip.tv/file/5859343"><![CDATA[<iframe src="http://blip.tv/play/AYLm1VMC.html?p=1" width="480" height="390" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#AYLm1VMC" style="display:none"></embed>]]></media:player>
<media:title>My Healthy Food List To Stock Up Your Kitchen</media:title>
<media:thumbnail url="http://a.images.blip.tv/notfound-episode.png"/>
</item>
__EOS__
TRAILER = <<__EOS__
</channel>
</rss>
__EOS__
def sample(elements)
HEADER + ELEMENT * elements + TRAILER
end
Benchmark.bmbm do |bm|
[1, 10, 100, 1000].each do |elements|
xml = sample(elements)
bm.report("#{elements} elements") do
100.times do
Nokogiri::XML(xml)
end
end
end
end
% jruby -v
jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-12 1e17517) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04-ea) [linux-amd64-java]
% ruby -v
ruby 1.9.3p6 (2011-12-20 revision 34080) [x86_64-linux]
% jruby -rubygems merbist.rb
Rehearsal -------------------------------------------------
1 elements 1.054000 0.000000 1.054000 ( 1.054000)
10 elements 0.663000 0.000000 0.663000 ( 0.664000)
100 elements 1.396000 0.000000 1.396000 ( 1.396000)
1000 elements 12.070000 0.000000 12.070000 ( 12.070000)
--------------------------------------- total: 15.183000sec
user system total real
1 elements 0.124000 0.000000 0.124000 ( 0.124000)
10 elements 0.193000 0.000000 0.193000 ( 0.193000)
100 elements 1.143000 0.000000 1.143000 ( 1.143000)
1000 elements 11.484000 0.000000 11.484000 ( 11.484000)
% ruby -rubygems merbist.rb
Rehearsal -------------------------------------------------
1 elements 0.020000 0.000000 0.020000 ( 0.022182)
10 elements 0.150000 0.000000 0.150000 ( 0.148458)
100 elements 1.260000 0.010000 1.270000 ( 1.269961)
1000 elements 12.730000 0.030000 12.760000 ( 12.769272)
--------------------------------------- total: 14.200000sec
user system total real
1 elements 0.040000 0.000000 0.040000 ( 0.039293)
10 elements 0.140000 0.000000 0.140000 ( 0.143851)
100 elements 1.250000 0.000000 1.250000 ( 1.248226)
1000 elements 12.720000 0.050000 12.770000 ( 12.785584)
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment