Re: simplifying following-sibling and preceding-sibling

"Dmitry Lizorkin" <[email protected]> Fri, 14 Jan 2005 17:54:29 +0300
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
Hello!

Well, with the simplifications you suggested your implementation for
"sxml:following-sibling" and "sxml:preceding-sibling" calls the child axis
twice on the parent node of the context node:
 a) the first time the child axis is called when locating the parent of the
context node, i.e. in the body of "sxml:parent";
 b) the second time the child axis is called when you select siblings of the
context node.

The "tricky enough code" you mentioned in the implementation for
following-sibling and preceding-sibling axes provided in "sxpath-ext.scm" is
designed to eliminate the duplicate call to the child axis considered above.

I performed a small benchmark to compare the performance of your
implementation of following-sibling and preceding-sibling axes and their
implementation from "sxpath-ext.scm".

Consider the simple SXML document:

(define doc
    '(*TOP*
      (doc
       (elem)
       (elem)
       (elem)
       ...
       (elem))))

where the number of 'elem elements is N.
Select the middle 'elem element for the context node:

(define node
    (car
     ((sxpath "doc/elem[position()=floor(last() div 2)]")
      doc)))

For this context node "node", we now select its following-siblings and
preceding-siblings with different axes implementations. Parameter N is
varied, and we consider execution time in milliseconds.

N=100000
following-sibling from "sxpath-ext.scm":    532 ms
your implementation of following-sibling:     875 ms

N=500000
following-sibling from "sxpath-ext.scm":    2500 ms
your implementation of following-sibling:     3906 ms

N=1000000
following-sibling from "sxpath-ext.scm":    5484 ms
your implementation of following-sibling:     8999 ms

Results for precedins-sibling axis are similar.

Regards,
Dmitry





-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt