Re: Seeking peer review of new fast high level XML pull parser
Petr Pajas <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hallo Tyler, this looks great to me, congrats to a really nice and concise API ! -- Petr 2010/2/20 Tyler Riddle <[email protected]>: > Hi XML folks, > > I'm putting the finishing touches on XML::TreePuller which is a high > level very fast XML pull processor but I'd like to solicit the > feedback of the public before I publish the first version onto CPAN. > It is functional and almost ready for a release so feel free to test > it if you would like. I would appreciate any feedback people have > especially on the > documentation and interface - I'm aiming to be understandable at a > glance and easy to use. > > You can see the code for the module at > https://triddle.projecthut.com/svn/triddle/XML-TreePuller/lib/XML/TreePuller.pm > and there is a real-world example of the same interface (with an > insignificant change) in use in MediaWiki::DumpFile::Pages at > http://cpansearch.perl.org/src/TRIDDLE/MediaWiki-DumpFile-0.0.14/lib/MediaWiki/DumpFile/Pages.pm > (XML::TreePuller and MediaWiki::DumpFile::XML have a nearly identical > interface). > > How fast is it? In my benchmarks > (https://triddle.projecthut.com/svn/triddle/XML_Speed_Test/test_cases/) > it performs as follows: > > --- > - filename: datastore/20-simplewiki-20091021-pages-articles.xml > markup_density: 0.202659609191331 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > size: 227681797 > tests: > - MiB/sec: 25.6054577962408 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-LibXML-Reader.t > percentage: 100 > runtimes: > system: 0.74 > total: 8.48 > user: 7.74 > - MiB/sec: 12.450360212851 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-TreePuller_element.t > percentage: 205 > runtimes: > system: 0.51 > total: 17.44 > user: 16.93 > - MiB/sec: 9.98318538446536 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-TreePuller_config.t > percentage: 256 > runtimes: > system: 0.54 > total: 21.75 > user: 21.21 > - MiB/sec: 6.67489339416298 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-SAX-ExpatXS.t > percentage: 383 > runtimes: > system: 0.41 > total: 32.53 > user: 32.12 > - MiB/sec: 5.03441414588735 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-Parser.t > percentage: 508 > runtimes: > system: 0.71 > total: 43.13 > user: 42.42 > - MiB/sec: 3.21537512382825 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-LibXML-SAX.t > percentage: 796 > runtimes: > system: 0.82 > total: 67.53 > user: 66.71 > - MiB/sec: 1.06375799584618 > md5sum: 8fa1e9de18b8da7523ebfe2dac53482a > name: test/XML-Twig.t > percentage: 2407 > runtimes: > system: 1.73 > total: 204.12 > user: 202.39 > > Also here is an example just for good measure: > > #!/usr/bin/env perl > > use strict; > use warnings; > > use XML::TreePuller; > > sub gen_xml { > return <<EOF > > <wiki version="0.3"> > > <!-- schema says that there is always 1 siteinfo and zero or more page > elements follow --> > <siteinfo> > <sitename>ExamplePedia</sitename> > <url>http://example.pedia/</url> > <namespaces> > <namespace key="-1">Special</namespace> > <namespace key="0" /> > <namespace key="1">Talk</namespace> > </namespaces> > </siteinfo> > > <page> > <title>A good article</title> > <text>Some good content</text> > </page> > > <page> > <title>A bad article</title> > <text>Some bad content</text> > </page> > > </wiki> > > EOF > } > > sub element_example { > my $xml = XML::TreePuller->new(string => gen_xml()); > > print "Printing namespace names using configuration style:\n"; > > $xml->config('/wiki/siteinfo/namespaces/namespace' => 'short'); > > while(defined(my $element = $xml->next)) { > print $element->attribute('key'), ": ", $element->text, "\n"; > } > > print "End of namespace names\n"; > } > > sub subtree_example { > my $xml = XML::TreePuller->new(string => gen_xml()); > > print "Printing titles using a subtree:\n"; > > $xml->config('/wiki/page' => 'subtree'); > > while(defined(my $element = $xml->next)) { > print "Title: ", $element->get_elements('title')->text, "\n"; > } > > print "End of titles\n"; > } > > sub path_example { > my $xml = XML::TreePuller->new(string => gen_xml()); > > print "Printing path example:\n"; > > $xml->config('/wiki/siteinfo', 'subtree'); > $xml->config('/wiki/page/title', 'short'); > > while(my ($matched_path, $element) = $xml->next) { > print "Path: $matched_path\n"; > } > > print "End path example\n"; > } > > > element_example(); print "\n"; > subtree_example(); print "\n"; > path_example(); print "\n"; > > __END__ > > Output: > > Printing namespace names using configuration style: > -1: Special > 0: > 1: Talk > End of namespace names > > Printing titles using a subtree: > Title: A good article > Title: A bad article > End of titles > > Printing path example: > Path: /wiki/siteinfo > Path: /wiki/page/title > Path: /wiki/page/title > End path example > > > > > > > > > > Thanks everyone and I'm looking forward to seeing any feedback! > > Tyler Riddle > > -- > If you wish to make an apple pie from scratch you must first invent > the universe. -- Carl Sagan > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs