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?
C++ routine vs. Convert function performance
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 12
- Joined: Fri Jun 13, 2008 2:51 pm
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 12
- Joined: Fri Jun 13, 2008 2:51 pm
-
- Premium Member
- Posts: 12
- Joined: Fri Jun 13, 2008 2:51 pm
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?
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?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: