Created
May 20, 2013 20:53
-
-
Save ispedals/5615462 to your computer and use it in GitHub Desktop.
Compare performance of Mojo::DOM and XML::Smart
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
#!perl | |
use v5.16; | |
use utf8; | |
use XML::Smart; | |
use Mojo::DOM; | |
use Benchmark qw( timethese cmpthese ); | |
my $xml = <<'EOF'; | |
<?xml version='1.0' encoding='UTF-8'?><feed gd:etag="W/"A0ACRHgyfyp7I2A9WhNQGUo."" xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:gd="http://schemas.google.com/g/2005" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><id>tag:youtube.com,2008:user:chemicalsreact14:uploads</id><updated>2012-11-27T01:29:25.697Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><title>Uploads by chemicalsreact14</title><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14?v=2" rel="related" type="application/atom+xml" /><link href="http://www.youtube.com/channel/UC6PnMX0ZSS4hnqGRmByH4gA/videos" rel="alternate" type="text/html" /><link href="http://pubsubhubbub.appspot.com" rel="hub" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads?v=2" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/batch?v=2" rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads?start-index=1&max-results=25&v=2" rel="self" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads?alt=atom-service&v=2" rel="service" type="application/atomsvc+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><generator uri="http://gdata.youtube.com" version="2.1">YouTube data API</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag="W/"DkIDQX47eCp7I2A9WhJUEE4.""><id>tag:youtube.com,2008:video:yIYK0lU6h_E</id><published>2007-07-16T19:20:59.000Z</published><updated>2012-09-07T16:16:10.000Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Entertainment" /><title>BreyerFest 2007; documentary</title><content src="http://www.youtube.com/v/yIYK0lU6h_E?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=yIYK0lU6h_E&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/yIYK0lU6h_E/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/yIYK0lU6h_E/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/yIYK0lU6h_E?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="allowed" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="allowed" /><gd:comments><gd:feedLink countHint="25" href="http://gdata.youtube.com/feeds/api/videos/yIYK0lU6h_E/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Entertainment</media:category><media:content duration="17" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/yIYK0lU6h_E?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:content duration="17" expression="full" medium="video" type="video/3gpp" url="rtsp://v1.cache5.c.youtube.com/CigLENy73wIaHwnxhzpV0gqGyBMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="1" /><media:content duration="17" expression="full" medium="video" type="video/3gpp" url="rtsp://v6.cache3.c.youtube.com/CigLENy73wIaHwnxhzpV0gqGyBMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="6" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">Coming in August =)</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=yIYK0lU6h_E&feature=youtube_gdata_player" /><media:thumbnail height="90" time="00:00:08.500" url="http://i.ytimg.com/vi/yIYK0lU6h_E/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/yIYK0lU6h_E/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/yIYK0lU6h_E/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:00:04.250" url="http://i.ytimg.com/vi/yIYK0lU6h_E/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:00:08.500" url="http://i.ytimg.com/vi/yIYK0lU6h_E/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:00:12.750" url="http://i.ytimg.com/vi/yIYK0lU6h_E/3.jpg" width="120" yt:name="end" /><media:title type="plain">BreyerFest 2007; documentary</media:title><yt:duration seconds="17" /><yt:uploaded>2007-07-16T19:20:59.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>yIYK0lU6h_E</yt:videoid></media:group><gd:rating average="3.4615386" max="5" min="1" numRaters="26" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="7695" /><yt:rating numDislikes="10" numLikes="16" /></entry><entry gd:etag="W/"AkAMRn47eCp7I2A9WhNRGUU.""><id>tag:youtube.com,2008:video:PQRnuhdDy4k</id><published>2007-06-21T01:33:12.000Z</published><updated>2012-11-15T14:13:07.000Z</updated><app:control><yt:state name="restricted" reasonCode="limitedSyndication">Syndication of this video was restricted.</yt:state></app:control><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Pets & Animals" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Animals" /><title>Halleujah - Horses</title><content src="http://www.youtube.com/v/PQRnuhdDy4k?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=PQRnuhdDy4k&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/PQRnuhdDy4k/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/PQRnuhdDy4k/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/PQRnuhdDy4k?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="allowed" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="denied" /><gd:comments><gd:feedLink countHint="46" href="http://gdata.youtube.com/feeds/api/videos/PQRnuhdDy4k/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Pets & Animals" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Animals</media:category><media:content duration="225" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/PQRnuhdDy4k?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">Horses set to music by Paramore.</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=PQRnuhdDy4k&feature=youtube_gdata_player" /><media:thumbnail height="90" time="00:01:52.500" url="http://i.ytimg.com/vi/PQRnuhdDy4k/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/PQRnuhdDy4k/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/PQRnuhdDy4k/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:00:56.250" url="http://i.ytimg.com/vi/PQRnuhdDy4k/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:01:52.500" url="http://i.ytimg.com/vi/PQRnuhdDy4k/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:02:48.750" url="http://i.ytimg.com/vi/PQRnuhdDy4k/3.jpg" width="120" yt:name="end" /><media:title type="plain">Halleujah - Horses</media:title><yt:duration seconds="225" /><yt:uploaded>2007-06-21T01:33:12.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>PQRnuhdDy4k</yt:videoid></media:group><gd:rating average="4.724138" max="5" min="1" numRaters="58" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="11363" /><yt:rating numDislikes="4" numLikes="54" /></entry><entry gd:etag="W/"D0AMRX47eCp7I2A9WhNSE0o.""><id>tag:youtube.com,2008:video:N-mZSMMfxvc</id><published>2007-01-07T02:37:10.000Z</published><updated>2012-10-27T22:09:44.000Z</updated><app:control><yt:state name="restricted" reasonCode="limitedSyndication">Syndication of this video was restricted.</yt:state></app:control><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Film & Animation" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Film" /><title>Into The Rush</title><content src="http://www.youtube.com/v/N-mZSMMfxvc?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=N-mZSMMfxvc&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/N-mZSMMfxvc/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/N-mZSMMfxvc/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/N-mZSMMfxvc?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="moderated" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="denied" /><gd:comments><gd:feedLink countHint="266" href="http://gdata.youtube.com/feeds/api/videos/N-mZSMMfxvc/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Film & Animation" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Film</media:category><media:content duration="194" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/N-mZSMMfxvc?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">I made this mid-2006 when I didn't have internet and was just playing with WMM after using the old version for 3 years. All pictures © Robert Vavra</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=N-mZSMMfxvc&feature=youtube_gdata_player" /><media:restriction relationship="deny" type="country">DE</media:restriction><media:thumbnail height="90" time="00:01:37" url="http://i.ytimg.com/vi/N-mZSMMfxvc/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/N-mZSMMfxvc/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/N-mZSMMfxvc/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:00:48.500" url="http://i.ytimg.com/vi/N-mZSMMfxvc/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:01:37" url="http://i.ytimg.com/vi/N-mZSMMfxvc/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:02:25.500" url="http://i.ytimg.com/vi/N-mZSMMfxvc/3.jpg" width="120" yt:name="end" /><media:title type="plain">Into The Rush</media:title><yt:duration seconds="194" /><yt:uploaded>2007-01-07T02:37:10.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>N-mZSMMfxvc</yt:videoid></media:group><gd:rating average="4.810753" max="5" min="1" numRaters="465" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="138707" /><yt:rating numDislikes="22" numLikes="443" /></entry><entry gd:etag="W/"CkYARX47eCp7I2A9WhJbEEU.""><id>tag:youtube.com,2008:video:yrkqTqdNSO4</id><published>2006-06-21T19:48:24.000Z</published><updated>2012-09-19T18:42:24.000Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Entertainment" /><title>where</title><content src="http://www.youtube.com/v/yrkqTqdNSO4?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=yrkqTqdNSO4&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/yrkqTqdNSO4/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/yrkqTqdNSO4/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/yrkqTqdNSO4?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="moderated" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="allowed" /><gd:comments><gd:feedLink countHint="13" href="http://gdata.youtube.com/feeds/api/videos/yrkqTqdNSO4/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Entertainment</media:category><media:content duration="395" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/yrkqTqdNSO4?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:content duration="395" expression="full" medium="video" type="video/3gpp" url="rtsp://v7.cache4.c.youtube.com/CigLENy73wIaHwnuSE2nTiq5yhMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="1" /><media:content duration="395" expression="full" medium="video" type="video/3gpp" url="rtsp://v7.cache1.c.youtube.com/CigLENy73wIaHwnuSE2nTiq5yhMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="6" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">narnia montage to the song where.</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=yrkqTqdNSO4&feature=youtube_gdata_player" /><media:restriction relationship="deny" type="country">BE BG BA HR DE BH SY HU JO FI FO SK LB PT NO TR LI LV IQ LT LU ES RO PL CH AE GR EE YE IS IR ZA AL CZ CY AT NL AD IE GI ME OM MC IL RS MK QA MT SI KW SM DK SA IT UA SE GB</media:restriction><media:thumbnail height="90" time="00:03:17.500" url="http://i.ytimg.com/vi/yrkqTqdNSO4/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/yrkqTqdNSO4/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/yrkqTqdNSO4/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:01:38.750" url="http://i.ytimg.com/vi/yrkqTqdNSO4/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:03:17.500" url="http://i.ytimg.com/vi/yrkqTqdNSO4/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:04:56.250" url="http://i.ytimg.com/vi/yrkqTqdNSO4/3.jpg" width="120" yt:name="end" /><media:title type="plain">where</media:title><yt:duration seconds="395" /><yt:uploaded>2006-06-21T19:48:24.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>yrkqTqdNSO4</yt:videoid></media:group><gd:rating average="4.047619" max="5" min="1" numRaters="21" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="7566" /><yt:rating numDislikes="5" numLikes="16" /></entry><entry gd:etag="W/"CUcGSH47eCp7I2A9WhNREEU.""><id>tag:youtube.com,2008:video:9cT4DD-t0_w</id><published>2006-06-21T19:40:26.000Z</published><updated>2012-11-05T02:37:09.000Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Entertainment" /><title>new world</title><content src="http://www.youtube.com/v/9cT4DD-t0_w?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=9cT4DD-t0_w&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/9cT4DD-t0_w/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/9cT4DD-t0_w/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/9cT4DD-t0_w?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="moderated" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="allowed" /><gd:comments><gd:feedLink countHint="17" href="http://gdata.youtube.com/feeds/api/videos/9cT4DD-t0_w/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Entertainment</media:category><media:content duration="196" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/9cT4DD-t0_w?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:content duration="196" expression="full" medium="video" type="video/3gpp" url="rtsp://v6.cache2.c.youtube.com/CigLENy73wIaHwn8060_DPjE9RMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="1" /><media:content duration="196" expression="full" medium="video" type="video/3gpp" url="rtsp://v8.cache1.c.youtube.com/CigLENy73wIaHwn8060_DPjE9RMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="6" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">a narnia montage set to New World.</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=9cT4DD-t0_w&feature=youtube_gdata_player" /><media:restriction relationship="deny" type="country">DE</media:restriction><media:thumbnail height="90" time="00:01:38" url="http://i.ytimg.com/vi/9cT4DD-t0_w/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/9cT4DD-t0_w/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/9cT4DD-t0_w/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:00:49" url="http://i.ytimg.com/vi/9cT4DD-t0_w/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:01:38" url="http://i.ytimg.com/vi/9cT4DD-t0_w/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:02:27" url="http://i.ytimg.com/vi/9cT4DD-t0_w/3.jpg" width="120" yt:name="end" /><media:title type="plain">new world</media:title><yt:duration seconds="196" /><yt:uploaded>2006-06-21T19:40:26.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>9cT4DD-t0_w</yt:videoid></media:group><gd:rating average="4.75" max="5" min="1" numRaters="48" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="5594" /><yt:rating numDislikes="3" numLikes="45" /></entry><entry gd:etag="W/"CUMESX47eCp7I2A9WhNQGUo.""><id>tag:youtube.com,2008:video:WUJOY7y_8QQ</id><published>2006-06-19T19:39:21.000Z</published><updated>2012-11-26T23:43:28.000Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><category label="Pets & Animals" scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Animals" /><title>horses</title><content src="http://www.youtube.com/v/WUJOY7y_8QQ?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" /><link href="http://www.youtube.com/watch?v=WUJOY7y_8QQ&feature=youtube_gdata" rel="alternate" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/videos/WUJOY7y_8QQ/responses?v=2" rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/videos/WUJOY7y_8QQ/related?v=2" rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" /><link href="http://m.youtube.com/details?v=WUJOY7y_8QQ" rel="http://gdata.youtube.com/schemas/2007#mobile" type="text/html" /><link href="http://gdata.youtube.com/feeds/api/users/6PnMX0ZSS4hnqGRmByH4gA?v=2" rel="http://gdata.youtube.com/schemas/2007#uploader" type="application/atom+xml" /><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14/uploads/WUJOY7y_8QQ?v=2" rel="self" type="application/atom+xml" /><author><name>chemicalsreact14</name><uri>http://gdata.youtube.com/feeds/api/users/chemicalsreact14</uri><yt:userId>6PnMX0ZSS4hnqGRmByH4gA</yt:userId></author><yt:accessControl action="comment" permission="allowed" /><yt:accessControl action="commentVote" permission="allowed" /><yt:accessControl action="videoRespond" permission="moderated" /><yt:accessControl action="rate" permission="allowed" /><yt:accessControl action="embed" permission="allowed" /><yt:accessControl action="list" permission="allowed" /><yt:accessControl action="autoPlay" permission="allowed" /><yt:accessControl action="syndicate" permission="allowed" /><gd:comments><gd:feedLink countHint="8547" href="http://gdata.youtube.com/feeds/api/videos/WUJOY7y_8QQ/comments?v=2" rel="http://gdata.youtube.com/schemas/2007#comments" /></gd:comments><media:group><media:category label="Pets & Animals" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Animals</media:category><media:content duration="196" expression="full" isDefault="true" medium="video" type="application/x-shockwave-flash" url="http://www.youtube.com/v/WUJOY7y_8QQ?version=3&f=user_uploads&app=youtube_gdata" yt:format="5" /><media:content duration="196" expression="full" medium="video" type="video/3gpp" url="rtsp://v8.cache4.c.youtube.com/CigLENy73wIaHwkE8b-8Y05CWRMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="1" /><media:content duration="196" expression="full" medium="video" type="video/3gpp" url="rtsp://v6.cache4.c.youtube.com/CigLENy73wIaHwkE8b-8Y05CWRMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" yt:format="6" /><media:credit role="uploader" scheme="urn:youtube" yt:display="chemicalsreact14">chemicalsreact14</media:credit><media:description type="plain">video I made featuring the horses of Iron Springs Farm. Just for fun.Song: Chemicals React - Aly & AJNo, I am NOT riding in any of the clips, nor did I film the videos. It is just a fun, 'no-copyright-infringement-intended' video I made on Windows Movie Maker :)</media:description><media:keywords /><media:license href="http://www.youtube.com/t/terms" type="text/html">youtube</media:license><media:player url="http://www.youtube.com/watch?v=WUJOY7y_8QQ&feature=youtube_gdata_player" /><media:restriction relationship="deny" type="country">RU DE BY</media:restriction><media:thumbnail height="90" time="00:01:38" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/default.jpg" width="120" yt:name="default" /><media:thumbnail height="180" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/mqdefault.jpg" width="320" yt:name="mqdefault" /><media:thumbnail height="360" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/hqdefault.jpg" width="480" yt:name="hqdefault" /><media:thumbnail height="90" time="00:00:49" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/1.jpg" width="120" yt:name="start" /><media:thumbnail height="90" time="00:01:38" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/2.jpg" width="120" yt:name="middle" /><media:thumbnail height="90" time="00:02:27" url="http://i.ytimg.com/vi/WUJOY7y_8QQ/3.jpg" width="120" yt:name="end" /><media:title type="plain">horses</media:title><yt:duration seconds="196" /><yt:uploaded>2006-06-19T19:39:21.000Z</yt:uploaded><yt:uploaderId>UC6PnMX0ZSS4hnqGRmByH4gA</yt:uploaderId><yt:videoid>WUJOY7y_8QQ</yt:videoid></media:group><gd:rating average="4.761241" max="5" min="1" numRaters="8896" rel="http://schemas.google.com/g/2005#overall" /><yt:statistics favoriteCount="0" viewCount="6755268" /><yt:rating numDislikes="531" numLikes="8365" /></entry></feed> | |
EOF | |
my $r = timethese( | |
-10, | |
{ | |
MOJO => sub { | |
my $ret = []; | |
my $dom = Mojo::DOM->new($xml); | |
for ( $dom->find('media\:group')->each ) { | |
my $title = $_->at('media\:title')->text; | |
my $author = $_->at('yt\:uploaderId')->text; | |
$author = | |
sprintf | |
'http://gdata.youtube.com/feeds/api/users/%s/uploads?v=2', | |
$author; | |
my $id = $_->at('yt\:videoid')->text; | |
my @thumbs = | |
map { $_->{url} } | |
( $_->find('media\:thumbnail')->each )[ -3 .. -1 ]; | |
my $duration = $_->at('yt\:duration')->{seconds}; | |
push( @$ret, [ $title, $author, $id, $duration, \@thumbs ] ); | |
} | |
return @$ret; | |
}, | |
MOJO_Smart => sub { | |
my $ret = []; | |
my $dom = Mojo::DOM->new($xml); | |
for ( $dom->feed->find('entry')->each ) { | |
my $title = $_->title->text; | |
my $author = $_->author->{uri} . '/uploads?v=2'; | |
my $id = $_->at('media\:group')->at('yt\:videoid')->text; | |
my @thumbs = | |
map { $_->{url} } | |
( $_->at('media\:group')->find('media\:thumbnail')->each) | |
[ -3 .. -1 ]; | |
my $duration = | |
$_->at('media\:group')->at('yt\:duration')->{seconds}; | |
push( @$ret, [ $title, $author, $id, $duration, \@thumbs ] ); | |
} | |
return @$ret; | |
}, | |
SMART => sub { | |
my $ret = []; | |
my $x = XML::Smart->new($xml); | |
for ( @{ $x->{feed}->{entry} } ) { | |
my $title = $_->{title}->content; | |
my $author = $_->{author}->{uri}->content . '/uploads?v=2'; | |
my $id = $_->{'media:group'}->{'yt:videoid'}->content; | |
my @thumbs = | |
map { $_->{url} } | |
@{ $_->{'media:group'}->{'media:thumbnail'} }[ -3 .. -1 ]; | |
my $duration = $_->{'media:group'}->{'yt:duration'}->{seconds}; | |
push( @$ret, [ $title, $author, $id, $duration, \@thumbs ] ); | |
} | |
return @$ret; | |
}, | |
} | |
); | |
cmpthese $r; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment