Author |
Message
|
PP327475 |
Posted: Tue Mar 03, 2015 4:55 am Post subject: The better Conditional Statement in ESQL |
|
|
Newbie
Joined: 03 Mar 2015 Posts: 2
|
Hi,
I wanted to know with respect to efficiency which is better:
1.If Else ElseIF
2.CASE when
Which is faster when it comes to ESQL processing? |
|
Back to top |
|
 |
adubya |
Posted: Tue Mar 03, 2015 5:00 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
I would imagine the answer is "it depends..."
Run a user trace and look at the invocations involved / time taken for both of the approaches.
Last edited by adubya on Tue Mar 03, 2015 5:17 am; edited 1 time in total |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Mar 03, 2015 5:10 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
My preference is for then there are more that 3 items in the IF ... ELSE IF
then I use a CASE structure.
It is a lot more readable and maintainable IMHO.
And a lot more extensible as well. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 03, 2015 5:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
adubya wrote: |
I would imagine the answer is "it depends..." |
My personal view lines up with that of my worthy associate; anything more than a few items in an IF ELSE IF group is more readable and maintainable as a CASE structure.
I would also wonder if, assuming an IF ELSE IF turned out to be more efficient, the difference in execution time between that and a CASE statement would be worth the additional time taken in future development and problem resolution.
It's also not the first place I'd look to improve a poorly performing flow.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
PP327475 |
Posted: Tue Mar 03, 2015 5:37 am Post subject: |
|
|
Newbie
Joined: 03 Mar 2015 Posts: 2
|
Hey guys,
Thanks for the instant reply.
Well for my case theres like i guess 5 conditions and one default and each condtion perfomring additional 2 statements.
The look and readability is a second thing.
Priority goes to processing as this flow takes in a lot of data traffic.
Il try and see waht the user trace tells me.
Will let ul know |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 03, 2015 6:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
PP327475 wrote: |
Il try and see waht the user trace tells me. |
Experimentation is the key.
One suggestion if you want to try this under load (where a user trace becomes unwieldy) would be to enable the monitoring and statistics for the flow, with specific reference to the node with this construct. You can then gather timings for the flow and the node (but not, I accept, that piece of ESQL) and see which version performs better on average over a large number of executions.
You clearly would also need something to process and interpret the stats; one cheap solution I've used is a simple flow to dump the event tags into a db and then import the data to Excel! Other and better solutions are undoubtably available, and all would be better than a user trace from a load test. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 03, 2015 6:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
PP327475 wrote: |
Priority goes to processing as this flow takes in a lot of data traffic. |
For the record, how much data traffic is "a lot", what's the SLA on the flow and how chunky is the server running broker?
You may find in load testing you don't have as much of a problem as you think..... _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|