C++ routine vs. Convert function performance

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
John Corbin
Premium Member
Premium Member
Posts: 12
Joined: Fri Jun 13, 2008 2:51 pm

C++ routine vs. Convert function performance

Post by John Corbin »

I have programed in C/C++ for many years. It is coming back slowly though.

I currently use this code in a transformer stage, in a PX job, to replace certain Ascii control characters to space in free format text fields:

Convert(Char(0):Char(10):Char(13),' ', link.column)

Then i stumbled on this thread from some time ago:

viewtopic.php?t=132495

I kinda understand what the code does but i am wondering if the performance of my original Convert function is better or worse than the C routine in the thread?

C obviously has overhead associated with it in terms memory allocation etc.

Is the Convert function written in C++ as well?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

I would suggest to use in-built convert function if it fits your requirements.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can improve the performance of the posted Convert() function by initializing a stage variable to the result of the concatenated Char() functions, and not further deriving the stage variable. That way, you aren't re-evaluating the same thing for every row. Your expression then becomes

Code: Select all

Convert(svCharsToDrop, "", InLink.TheString)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
John Corbin
Premium Member
Premium Member
Posts: 12
Joined: Fri Jun 13, 2008 2:51 pm

Post by John Corbin »

Thanks for that reminder about stage variables. applying it now :D
John Corbin
Premium Member
Premium Member
Posts: 12
Joined: Fri Jun 13, 2008 2:51 pm

Post by John Corbin »

One final question...

I am using this isn a stage variable:

CHAR(0):CHAR(1):CHAR(2):CHAR(3):CHAR(4):CHAR(5):CHAR(6):CHAR(7):CHAR(8):CHAR(9):CHAR(10):CHAR(11):CHAR(12):CHAR(13):CHAR(14)
:CHAR(15):CHAR(16):CHAR(17):CHAR(18):CHAR(19):CHAR(20):CHAR(21):CHAR(22):CHAR(23):CHAR(24):CHAR(25):CHAR(26):CHAR(27):CHAR(28):CHAR(29):CHAR(30):CHAR(31)

is there a way to make this simpler by specifying a range of values instead of listing each one?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply