[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using memory addressing to retrieve a value vice

Subject: Re: Using memory addressing to retrieve a value vice using a software string library to retrieve a value
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Nov 2015 12:43:18 -0000
Re:  Using memory addressing to retrieve a value vice
On 20 November 2015 at 12:13, Costello, Roger L. costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi Folks,
>
> I want to retrieve "west".
>
> Which of these is faster?
>
> -------------------
> Approach #1
> -------------------
> The <edge> element contains text:
>
>         <edge>garden west door</edge>
>
> "west" is retrieved using this XPath:
>
>         substring-before(substring-after(., ' '), ' ')
>
> Note: assume that <edge> is the context node.
>
> -------------------
> Approach #2
> -------------------
> The <edge> element contains markup:
>
>         <edge>
>             <garden/>
>             <west/>
>             <door/>
>         </edge>
>
> "west" is retrieved using this XPath:
>
>         *[2]/name()
>
>
> I believe that Approach #2 is much, much faster. Do you agree?
>
> As I see it, Approach #2 is simply a memory addressing task (which computers
do very well) to obtain <west/> and then output the symbols at that memory
address. Approach #1, on the other hand, requires the use of software string
libraries, which, I imagine, results in hundreds or thousands of machine
instructions. In fact, I would imagine that Approach #2 is hundreds or
thousands of times faster than Approach #1. Do you agree?
>
> /Roger

In addition to what Mike said,

<edge>garden west door</edge>

is two nodes (an element and text)


    <edge>
            <garden/>
            <west/>
            <door/>
    </edge>

is four or eight nodes (depending on whether you have white space text
nodes or not) so it depends a lot on your internal object model, but
the second one might be a lot bigger. If you run out of memory then
speed isn't really the issue. But the second form could take less
memory than the first if the element names are repeated often and some
kind of name pool is used for element names but not text content.

Nothing really that you can say in general.

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.