There's a big difference between using the "search" (e.g. xpath) interface on top of a parsed DOM and running over the entire tree, testing each node for what it is you're looking for. Code gets a little uglier when doing the latter, it's not as elegant/clean, but performance starts kicking in when you do it. Moving from xpath search-style parsing, to tree walking yielded ~3x performance improvement in parsing for me. I suspect that going all the way to either Nokogiri's Reader or SAX interface would yield an additional 10% improvement over that. However, I'm stoping here for now as the readability/complexity detriment in doing a full Reader/SAX stack-maintenance model doesn't feel worth it at the moment. I would like to try pauldix's SAX machine declarative parser (built on Nokogiri) and run some benchmarks, but... another day.
Old:
doc = Nokogiri::XML.parse(some_xml_string) { |cfg| cfg.noblanks }
doc.xpath('/xmlns:feed/xmlns:entry').each do |entry|
at = entry.xpath('xmlns:published').text
id = entry.xpath('xmlns:id').text
...
end
New:
doc = Nokogiri::XML.parse(some_xml_string) { |cfg| cfg.noblanks }
doc.root.children.each do |node|
if node.name == 'entry'
node.children.each do |sub_e|
at = sub_e.inner_text if sub_e.name == 'published'
id = sub_e.inner_text if sub_e.name == 'id'
end
end
...
end
76 comments:
i'm a little late to the party, but hey, thanks so much for posting this. In my case, it was a factor 10 speed up. this probably means nokogiri's xpath implementation could be optimized further. maybe with indices?
generic xanax drug test results for xanax - 4mg xanax high
generic xanax xanax buy online no prescription uk - buy generic xanax online no prescription
xanax online xanax bars 3mg - what type of drug is xanax
buy tramadol cod buy tramadol in europe - buy tramadol usa
buy tramadol online best place buy tramadol online - generic tramadol online
xanax online xanax effects relationships - xanax withdrawal caffeine
buy tramadol online long does 50mg tramadol take kick - tramadol high forum
buy carisoprodol carisoprodol wp 5901 - buy carisoprodol online
xanax online xanax effects and dosage - generic xanax gg 258
order tramadol no prescription tramadol 50 mg dosage - buy tramadol online cod only
buy tramadol online tramadol 50mg tablets used - tramadol 200mg
buy carisoprodol is soma 350 mg a narcotic - carisoprodol 350 mg tablet qua
carisoprodol 350 mg soma carisoprodol drug test - what is soma carisoprodol
buy tramadol online tramadol normal dose - tramadol addiction potential
buy tramadol online cheap tramadol no prescription overnight - tramadol 50mg hcl high
xanax online xanax quad bars - xanax and alcohol death
generic carisoprodol carisoprodol soma side effects - buy soma carisoprodol online
how to buy xanax online legally xanax rectal - xanax bars drug info
buy carisoprodol cheap carisoprodol soma wiki - order carisoprodol online
xanax no rx xanax uses - taking 4 xanax bars
buy xanax valium online florida xanax 832 - buy xanax in china
xanax online seroquel xanax drug interactions - xanax effects thyroid
xanax online xanax kratom - generic xanax 0.25
buy carisoprodol carisoprodol 350 mg street value - carisoprodol tablets dosage
buy tramadol online tramadol withdrawal+muscle aches - addiction of tramadol
buy cialis online cialis daily from usa - can you buy cialis over the counter in spain
buy tramadol online buy tramadol online echeck - buy tramadol online usa
xanax online can you buy xanax online no prescription - xanax drug class
tadalafil no prescription cialis price dubai - buy cialis 100mg
cialis online where to buy cialis no prescription - buy cialis daily use
xanax online buy xanax online usa - xanax online real
buy cialis online cialis levitra reviews - cialis 5mg daily reviews
xanax online xanax bars u94 - xanax effects synapse
cialis online cialis 2.5 - cialis refractory period
cialis online cheap cialis in australia - cialis online-versand
buy tramadol tramadol and breastfeeding - buy tramadol no rx
http://buytramadolonlinecool.com/#28875 tramadol for dogs what dosage - order tramadol 180
buy tramadol tablets tramadol hydrochloride 50mg tablets - tramadol online texas
http://buytramadolonlinecool.com/#56411 tramadol overdose dosage - is it illegal to purchase tramadol online
20000 :) Generic Azithromycin - order azithromycin online http://www.zithromaxhowtobuy.net/#order-zithromax, [url=http://www.zithromaxhowtobuy.net/#generic-azithromycin]Azithromycin No Prescription[/url]
20000 :) Buy Azithromycin - zithromax pills http://www.zithromaxhowtobuy.net/#generic-azithromycin, [url=http://www.zithromaxhowtobuy.net/#generic-azithromycin]Cheap Azithromycin[/url]
http://landvoicelearning.com/#30896 tramadol 50mg for animals - buy tramadol cod online
buy tramadol online tramadol 50mg not working - drug study tramadol generic name
buy tramadol tramadol iv - tramadol online no prescription overnight delivery
http://blog.dawn.com/dblog/buy/#34852 tramadol can you snort - tramadol clorhidrato 50 mg para que sirve
http://landvoicelearning.com/#30896 tramadol for dogs incontinence - tramadol cause high
buy tramadol no prescription tramadol for dogs human consumption - can you buy tramadol in greece
http://blog.dawn.com/dblog/buy/#blog tramadol ultracet dosage - tramadol hydrochloride 100 mg
buy tramadol tramadol for dogs human use - buytramadol.eu
ways to buy ativan online buy lorazepam without prescriptions - ativan side effects breathing
ways to buy ativan online 6 mg ativan too much - ativan sublingual lorazepam overdose
lorazepam 1mg buying ativan online in canada - ativan overdose pediatrics
purchase tramadol tramadol 50 mg side effects - buy tramadol online australia
buy xanax online xanax 2mg pill identifier - xanax withdrawal erowid
xanax generic xanax mg - xanax vs ativan
buy tramadol online where to buy tramadol in usa - why can you buy tramadol online
buy xanax online long does take 1mg xanax work - 0.5mg of alprazolam
buy tramadol online tramadol for dogs can humans take it - tramadol withdrawal how long does it last
Coal-black Rhinoceros - a adipose and stalwart animal. he did not as rotund as the bloodless rhinoceros, but still impressive - reaches the power 2-2, 2 m, lengths of up to 3, 15 m in height shoulders of 150-160 cm.
buy tramadol online without a prescription tramadol for dogs generic - tramadol hcl shelf life
order tramadol overnight tramadol 50 mg mfg zydus - buy tramadol online overnight usa
Hey there, I think your blog might be having browser compatibility issues.
When I look at your blog in Opera, it looks fine but when opening in Internet Explorer, it
has some overlapping. I just wanted to give you a quick heads up!
Other then that, terrific blog!
Here is my web page :: cheap dental implants
buy xanax online xanax 2 mg withdrawal - xanax bars blue lotus review
Thanks for the good writeup. It in reality was once a enjoyment account it.
Look complicated to far delivered agreeable from you!
By the way, how could we keep in touch?
Feel free to surf to my web blog Root Canal
Hello, just wanted to mention, I loved this blog post.
It was funny. Keep on posting!
Here is my webpage: Cheap Dental Implants
Uses and Benefits of Rubber Mulch Guard Against The Dangers
Of Toxic Mulch
Also visit my webpage; tree nursery Milwaukee
viagra online cialis cialis 10 mg
cialis comprar viagra viagra cialis 5mg cialis
comprar cialis cialis 5mg tadalafil cialis generique
URL acheter cialis generique acheter cialis
buy tramadol for dogs buy tramadol cod - tramadol online pharmacy
cheap cialis online cheap cialis cialis online buy cialis 5mg
buy herbal ambien buy ambien online no rx - buy ambien online us pharmacy
order 180 tramadol cod or order tramadol forum or can you buy tramadol onlinelegally or order tramadol with american express or tramadol tropfen online kaufen or tramadol 100mg online overnight or cheap tramadol online
Post a Comment