Merely speculation, but I'd guess that spammer_x on all of the iterations after the first one ends up inheriting the overhead of the UNINIT methods of the mutablebuffer objects created at the end of the prior iteration.  A better benchmark would be to run each of these in its own program execution.


On 5/29/07, Chip Davis <> wrote:
Okay, I'm quite sure I don't understand something going on here.  Out
of curiosity, I added a 'spammer_e' routine to use Parse instead of
Substr() but I got such anomalous results that I began to question the
metrics Rony was reporting.

Finally, I simply modified his 'spammer_a' routine to append the fixed
value of a variable instead of the next letter of the string:

::routine spammer_x
   parse arg string, rep
   do rep
      Newstring = left(string,1)
      Do I = 2 to length(string)
         Newstring = newstring'<Z>'s  --truncated substr() into a var
   return newstring

Here are the run times I got, pretty consistently:

run # 1, string length: 16
spammer_x: 0.030000 (No SUBSTR-BIF)
spammer_a: 0.030000 (SUBSTR-BIF)
spammer_b: 0.020000 (INSERT-BIF)
spammer_c: 0.041000 (MutableBuffer: append)
spammer_d: 0.020000 (MutableBuffer: insert)

s0: W<Z>*<Z>*< ... >*<Z>*<Z>* length: 61
s1: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 61
s2: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 61
s3: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 61
s4: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 61
run # 2, string length: 160
spammer_x: 1.392000 (No SUBSTR-BIF)
spammer_a: 0.650000 (SUBSTR-BIF)
spammer_b: 0.281000 (INSERT-BIF)
spammer_c: 0.350000 (MutableBuffer: append)
spammer_d: 0.261000 (MutableBuffer: insert)

s0: W<Z>*<Z>*< ... >*<Z>*<Z>* length: 637
s1: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 637
s2: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 637
s3: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 637
s4: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 637
run # 3, string length: 1600
spammer_x: 12.838000 (No SUBSTR-BIF)
spammer_a: 10.916000 (SUBSTR-BIF)
spammer_b: 14.280000 (INSERT-BIF)
spammer_c: 3.475000 (MutableBuffer: append)
spammer_d: 7.251000 (MutableBuffer: insert)

s0: W<Z>*<Z>*< ... >*<Z>*<Z>* length: 6397
s1: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 6397
s2: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 6397
s3: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 6397
s4: W<Z>h<Z>a< ... >a<Z>y<Z>. length: 6397
run # 4, string length: 16000 ... [Got tired of waiting]

Can anyone tell me how the hell a simple variable reference can take
longer than a call to Substr() AND a variable reference?

I'm not sure I trust Time() to give me an accurate measure of elapsed
time anymore...


On 5/29/07 10:37 Rony G. Flatscher said:
> Here are the timings of the attached little program.

This email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
Oorexx-devel mailing list