• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: efficiency of Xquery vs NSXMLElement attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: efficiency of Xquery vs NSXMLElement attributes


  • Subject: Re: efficiency of Xquery vs NSXMLElement attributes
  • From: Kieren Eaton <email@hidden>
  • Date: Fri, 12 Dec 2008 07:30:51 +0900

Thanks Mike

On 12/12/2008, at 2:24 AM, Michael Ash wrote:

On Thu, Dec 11, 2008 at 1:00 AM, Kieren Eaton <email@hidden> wrote:
Hi All

I know there are always several ways to do things and have come across
something which puzzles me as to
the efficiency of these 2 ways of getting the same data from an NSXMLNode
object.


for this exercise assume theNode is an NSXMLNode object which has been
initialized and contains data and an attribute called class with something
in it.


Scenario 1

NSXMLElement *nodeAsElement = (NSXMLElement *)theNode;
NSString *attribContent = [[nodeAsElement attributeForName:@"class"]
stringValue];
NSLog(@"class contains %@",attribContent);

Scenario 2

NSString *attribContent = [[theNode objectsForXQuery:@"data(@class)"
error:nil] objectAtIndex:0];
NSLog(@"class contains %@",attribContent);

these will and do produce the same data but for my own personal knowledge I
would like to know which is more efficient.
I use both in my code but am leaning more towards the xquery style for
readability and maintainability of larger more nested structures.


Comments appreciated

I'd guess that #1 is going to be faster, simply because #2 has to parse the string and #1 does not.

However, does it matter? Unless you're doing this over and over again
in a tight loop, it probably doesn't make any difference which one you
use, so go for the one you think is more readable.
The strng gets checked on a random basis from about every couple of seconds to a couple of minutes depending on the length of the audio its associated with.

Thanks and I am using the more readable version with comments of course.

Kieren

If it really does make a difference then you're in a perfect situation
to find out for yourself. Try both, and measure how much time each one
takes, and you will have your answer.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >efficiency of Xquery vs NSXMLElement attributes (From: Kieren Eaton <email@hidden>)
 >Re: efficiency of Xquery vs NSXMLElement attributes (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Arggg...overrelease in table view cell, but where?
  • Next by Date: Re: Arggg...overrelease in table view cell, but where?
  • Previous by thread: Re: efficiency of Xquery vs NSXMLElement attributes
  • Next by thread: Core Data warning: to-many relation does not have an inverse
  • Index(es):
    • Date
    • Thread