|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Which code is more efficient |
« View previous topic :: View next topic » |
Author |
Message
|
murdeep |
Posted: Wed Jul 05, 2006 7:20 am Post subject: Which code is more efficient |
|
|
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 |
|
 |
iceage |
Posted: Wed Jul 05, 2006 8:26 am Post subject: |
|
|
 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 |
|
 |
jefflowrey |
Posted: Wed Jul 05, 2006 2:49 pm Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Wed Jul 05, 2006 5:03 pm Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|