Adding to a container with += vs. ConIns()
While adding data to the end of a container there can be large savings by using += rather than ConIns. Try the code below and compare the results:
static void Containertest(Args _args)
{
int ticks;
Container con;
Random random = new Random();
int myrandom;
int i;
;
//Start on ins
ticks = WinApi::getTickCount();
for(i = 1; i <= 100000; i++)
{
myrandom = random.nextInt();
con = conins(con, i, myrandom);
}
ticks = WinAPI::getTickCount() – ticks;
info(strfmt(“Time taken via ConIns: %1”, ticks));
//Start on +=
ticks = WinApi::getTickCount();
for(i = 1; i <= 100000; i++)
{
myrandom = random.nextInt();
con += myrandom;
}
ticks = WinAPI::getTickCount() – ticks;
info(strfmt(“Time taken via +=: %1”, ticks));
}