Consider the following three code snippets:
Code: Select all
// Option 1
foreach object in someCollection do
str2 := object.someMethodThatReturnsAString();
str1 := str1 & str2;
endforeach;
Code: Select all
// Option 2
foreach object in someCollection do
str1 := str1 & object.someMethodThatReturnsAString();
endforeach;
Code: Select all
// Option 3
create c1 transient ;
foreach object in someCollection do
c1.slob := c1.slob & object.someMethodThatReturnsAString();
endforeach;
Code: Select all
Iterations Option 1 Option 2 Option 3
5000 9ms 300ms 499ms
10000 16ms 1461ms 3284ms
15000 27ms 5265ms 10463ms
20000 32ms 10174ms 23663ms
25000 40ms 16386ms 39234ms
30000 47ms 24329ms 60821ms
35000 55ms 34375ms 88573ms
40000 66ms 46343ms 120791ms
45000 84ms 65103ms 188288ms
50000 94ms 88301ms 210791ms
Code: Select all
Iterations Option 1 Option 2 Option 3
100 3ms 55ms 110ms
200 6ms 288ms 580ms
300 8ms 747ms 1489ms
400 11ms 1384ms 2918ms
500 13ms 2315ms 5030ms
Cheers,
BeeJay.