Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
Close
From: Rony G. Flatscher <Rony.F<latscher@wu...>  20070529 10:37:20
Attachments:
Message as HTML

rep=1000 s_ori="What a nice day." len=10  length of resulting string to display fact=10  factor mult=1 do i=1 to 4 s=s_ori~copies(mult) say "run #" i", string length:" length(s) call time "R" s1=spammer_a(s,rep) say "spammer_a:" time("R") "(SUBSTRBIF)" s2=spammer_b(s,rep) say "spammer_b:" time("R") "(INSERTBIF)" s3=spammer_c(s,rep) say "spammer_c:" time("R") "(MutableBuffer: append)" s4=spammer_d(s,rep) say "spammer_d:" time("R") "(MutableBuffer: insert)" say say "s1:" s1~left(len) "..." s1~right(len) "length:" s1~length say "s2:" s2~left(len) "..." s2~right(len) "length:" s2~length say "s3:" s3~left(len) "..." s3~right(len) "length:" s3~length say "s4:" s4~left(len) "..." s4~right(len) "length:" s4~length say ""~copies(len+10) mult=mult*fact  next time 10 times as many characters end ::routine spammer_a parse arg string, rep do rep Newstring = left(string,1) Do I = 2 to length(string) Newstring = newstring'<Z>'substr(string,I,1) End end return newstring ::routine spammer_b parse arg string, rep do rep Newstring = string Do I=length(newstring)1 to 1 by 1 newstring=insert('<Z>', newstring, i) End end return newstring ::routine spammer_c parse arg string, rep do rep m=.mutableBuffer~new(, length(string)*3) m~append(string~left(1)) Do I = 2 to length(string) m~~append('<Z>')~~append(substr(string,I,1)) End end return m~string ::routine spammer_d parse arg string, rep do rep m=.mutableBuffer~new(string, length(string)*3) Do I=m~length1 to 1 by 1 m~insert('<Z>', i) End end return m~string 
From: Chip Davis <chip@av...>  20070529 23:25:49

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 s='*' do rep Newstring = left(string,1) Do I = 2 to length(string) Newstring = newstring'<Z>'s truncated substr() into a var End end return newstring Here are the run times I got, pretty consistently: C:\Chip\bin>spammer run # 1, string length: 16 spammer_x: 0.030000 (No SUBSTRBIF) spammer_a: 0.030000 (SUBSTRBIF) spammer_b: 0.020000 (INSERTBIF) 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 SUBSTRBIF) spammer_a: 0.650000 (SUBSTRBIF) spammer_b: 0.281000 (INSERTBIF) 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 SUBSTRBIF) spammer_a: 10.916000 (SUBSTRBIF) spammer_b: 14.280000 (INSERTBIF) 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... Chip On 5/29/07 10:37 Rony G. Flatscher said: > > Here are the timings of the attached little program. 
From: Rick McGuire <object.rexx@gm...>  20070529 23:38:28
Attachments:
Message as HTML

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. Rick On 5/29/07, Chip Davis <chip@...> 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 > s='*' > do rep > Newstring = left(string,1) > Do I = 2 to length(string) > Newstring = newstring'<Z>'s truncated substr() into a var > End > end > return newstring > > Here are the run times I got, pretty consistently: > > C:\Chip\bin>spammer > run # 1, string length: 16 > spammer_x: 0.030000 (No SUBSTRBIF) > spammer_a: 0.030000 (SUBSTRBIF) > spammer_b: 0.020000 (INSERTBIF) > 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 SUBSTRBIF) > spammer_a: 0.650000 (SUBSTRBIF) > spammer_b: 0.281000 (INSERTBIF) > 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 SUBSTRBIF) > spammer_a: 10.916000 (SUBSTRBIF) > spammer_b: 14.280000 (INSERTBIF) > 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... > > Chip > > On 5/29/07 10:37 Rony G. Flatscher said: > > > > Here are the timings of the attached little program. > > > >  > This SF.net 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. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Oorexxdevel mailing list > Oorexxdevel@... > https://lists.sourceforge.net/lists/listinfo/oorexxdevel > 