Page 1 of 1

C++ routine vs. Convert function performance

Posted: Thu May 28, 2015 6:33 pm
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?

Posted: Fri May 29, 2015 1:11 am
by priyadarshikunal
I would suggest to use in-built convert function if it fits your requirements.

Posted: Fri May 29, 2015 1:15 am
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)

Posted: Fri May 29, 2015 5:26 am
by John Corbin
Thanks for that reminder about stage variables. applying it now :D

Posted: Tue Jun 02, 2015 11:12 am
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?

Posted: Tue Jun 02, 2015 4:26 pm
by ray.wurlod
No.