Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

toma (3098)

  (email not shown publicly)

Journal of toma (3098)

Monday January 13, 2003
12:12 AM

Comparing XML::Twig and XML::Filter::Dispatcher

[ #9920 ]
Comparing Twig and Dispatcher
I rewrote my XML::Twig program to use XML::Filter::Dispatcher in order to compare the approaches. I compared the simplicity of the code necessary to do the job, and the speed of execution.

The result was that XML::Twig ran 17 times faster, which surprised me.

The Dispatcher code was cleaner than the Twig code. This is because I was able to remove the code I wrote to get my Twig return values to come out in the correct order. The order of the data from Dispatcher worked the way that I had orgininally hoped that Twig would work.

The speed is a big deal for me, because the Twig code is actually already slower than I would like it to be. The Dispatcher code is probably not fast enough for my application. I'm tempted to write the code again and use a format other than XML to see how fast it runs.

It would be nice if I had a program that would automatically measure the complexity of a perl program. I would like to be able to compare the complexity of the implementations with a numerical technique.

If anyone wants to see the two approaches and the test data, let me know and I'll post it on tomacorp (We're not a corporation).

New Module Testing
I installed and tried PerlBean, which looks useful for automating the generation of perl objects. Before I use it in a real project, I need to understand if there is a way to use it so that the classes can be redesigned without losing work. The straightforward way looks like you would have to edit the class by hand after the initial run of the module, and if you want to run it again you would have to cut and paste the custom methods in again.

Perhaps there is a way around this. PerlBean would make a good core for a perl IDE, I think.

I sent a bug report to the author of PerlBean. It looks like the tutorial didn't get an update after an API change.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • XML::Filter::Dispatcher is definitely slower than TWIG. It's still young and it will probably never be as optimized as TWIG is for TWIG's purpose.

    That being said, you may want to look at the struct() and hash() extension functions that return Perl data structures something like TWIGs. <plug>My shiny, tiny new BFD [] module might help you see them:

       'foo' => [ 'hash()' => sub { use BFD; d xvalue } ],


    Along with optmization, I'd like to enable X::F::D to gener

  • If anyone wants to see the two approaches and the test data, let me know and I'll post it

    Yes, please. You see, I've written my own, (as yet) unreleased XML parsing module which, from the little I know of XML::Twig, and judging by the name of the other module you mention, sounds like it's pretty much in the same realm. Before I even contemplate of releasing it, I'd like to port your test script in order to use my own module, and compare code and speed to the two modules you've used.

  • I have posted some comments on the article [] and a faster version of the XML::Twig code on the XML::Twig page [].