ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Which code is more efficient

Post new topic  Reply to topic
 Which code is more efficient « View previous topic :: View next topic » 
Author Message
murdeep
PostPosted: Wed Jul 05, 2006 7:20 am    Post subject: Which code is more efficient Reply with quote

Master

Joined: 03 Nov 2004
Posts: 211

A colleague has claimed that his code he has developed is more efficient than the product shipped...

Here is the product shipped:

Code:
   CREATE PROCEDURE CopyMessageHeaders() BEGIN
      DECLARE I INTEGER;
      DECLARE J INTEGER;
      SET I = 1;
      SET J = CARDINALITY(InputRoot.*[]);
      WHILE I < J DO
         SET OutputRoot.*[I] = InputRoot.*[I];
         SET I = I + 1;
      END WHILE;
   END;


here is his code:

Code:
SET OutputRoot = InputRoot;
DELETE FIELD OutputRoot.*[<];


I have doubts since his code copies the entire input message and then deletes the Body? Has anyone else seen this and determined if his code is more efficient than the default CopyMessageHeaders?
Back to top
View user's profile Send private message
iceage
PostPosted: Wed Jul 05, 2006 8:26 am    Post subject: Reply with quote

Acolyte

Joined: 12 Apr 2006
Posts: 68

My gut feeling , your friend is correct.
Because he is copying & deleting once instead of creating 'n'-1 trees.

Since 'n' is relatively small , most likely 3 or 4 for most of the common message , performance difference might be neglibile or none.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jul 05, 2006 2:49 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

No.

Set OutputRoot = InputRoot

WILL copy EVERYTHING.

If you then delete the BODY tree, you have done extra work on top of Copy Message Headers.

So, factually, your "friend's" code is less efficient.

It's easy enough to show this difference using trace.

Now, your friend may have been lead to believe that his code would be more efficient because of partial parsing - assuming that doing the tree copy and then only navigating to the last child of Root would do less parsing than having to navigate down the tree of each child of Root.

But all of those fields are going to have to be parsed at some point during the execution of the flow - unless they are deleted (and nobody deletes OutputRoot.Properties!). So at best, your friend's code has moved the parsing to a different point in the execution flow AND added MORE work - for the garbage collector at least.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 05, 2006 5:03 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Now imagine the impact if you are dealing with a 2MB message!!!

Stay with the CopyMessageHeaders() !!

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Which code is more efficient
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.