Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Created June 20, 2013 19:03
Show Gist options
  • Select an option

  • Save andyhuey/5825634 to your computer and use it in GitHub Desktop.

Select an option

Save andyhuey/5825634 to your computer and use it in GitHub Desktop.
string concatenation in AX
static void AjhTestTextBuffer(Args _args)
{
// ajh 2013-05-24: is the TextBuffer faster than using string concatenation?
// from http://www.mail-archive.com/axapta-knowledge-village@yahoogroups.com/msg07289.html
TextBuffer tb;
str a,b;
int i,j;
int ts, te;
ts = WinAPI::getTickCount();
tb = new TextBuffer();
a = '';
b = 'This will be appended to "a" multiple times. ';
for (i=0; i<30000; i++)
{
//j = xGlobal::randomPositiveInt32();
//b = int2str(j);
//a = a + b; // Finished in 68.02 secs!!??
//a += b; // Finished in 0.52 secs.
tb.appendText(b); // Finished in 0.17 secs.
}
a = tb.getText();
te = WinAPI::getTickCount();
info(strFmt("Finished in %1 secs.", (te-ts)/1000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment