Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: newlines

From: joel:neely:fedex at: 13-Nov-2001 1:37

Hello, all (again), Here's my latest round of benchmarks with all submissions (I think) but Ladislav's METHOD6 (called PRS6 below). I was getting errors from PRS6, but may have made a transcription error. Source for all new versions (PRS3 thru PRS6, and INS1) is included for anyone to check my typing... remprs3: func [s [string!] /local p a b] [ p: s while [ parse/all p [ to "..." 2 skip a: opt [some #"." b: (remove/part a b)] to end ] ][ p: a ] ] remprs4: func [s [string!] /local p a b] [ parse/all s [ any [ to "..." 2 skip a: opt [some #"." b: (remove/part a b)] :a ] ] ] remprs5: func [s [string!] /local t u] [ parse/all s [ any [ thru "..." t: any #"." u: [ (remove/part t: back t u) :t | :t ] ] to end ] ] remprs6: func [s [string!] /local t u w sub] [ sub: [ any #"." copy u [ to "..." 2 skip (w: [(t: change t u) sub]) | end (w: [(clear t)]) | to end (w: [(clear change t u)]) ] w ] parse/all s [opt [to "..." 2 skip t: sub] to end] ] remins1: func [s [string!] /local out start end1] [ out: clear "" parse/all s [ any [ start: thru "..." end1: any "." ( insert/part tail out start back end1 ) ] ] insert tail out start out ] Benchmark results from the same test harness as used before are as follows: 10 10000 xxxxxxxxx. ins1 0.0055324 15.7 prs4 0.0056476 16.1 prs5 0.0056954 16.2 pass 0.0057106 16.2 prs3 0.0058941 16.8 pany 0.0060686 17.3 binr 0.0109558 31.2 prs2 0.0170093 48.4 prs1 0.0351644 100 10 10000 xxxxx..... ins1 0.0263463 26.2 prs4 0.0521243 51.9 prs5 0.057153 56.9 prs3 0.0660708 65.8 pany 0.0735148 73.2 prs1 0.0783158 78 prs2 0.0814463 81.1 pass 0.0882192 87.8 binr 0.100443 100 10 10000 x......... ins1 0.0317953 6.1 prs4 0.0582377 11.2 prs5 0.0650405 12.5 prs1 0.0658213 12.6 prs2 0.0665257 12.7 prs3 0.0787273 15.1 pany 0.0864575 16.6 binr 0.1375208 26.3 pass 0.5222772 100 10 20000 xxxxxxxxx. ins1 0.0071699 10.6 prs4 0.0086906 12.8 prs5 0.0088449 13 prs3 0.0090889 13.4 pany 0.0095072 14 pass 0.0169069 24.9 binr 0.0187407 27.6 prs2 0.0309285 45.6 prs1 0.0678235 100 10 20000 xxxxx..... ins1 0.0490884 12.6 prs5 0.2070957 53.2 prs4 0.2101422 54 prs3 0.2295755 59 prs1 0.2382468 61.2 prs2 0.2507145 64.4 pany 0.2563284 65.8 binr 0.2993995 76.9 pass 0.3894038 100 10 20000 x......... ins1 0.0597987 2.6 prs5 0.2347959 10.3 prs4 0.2426656 10.6 prs2 0.2470482 10.8 prs1 0.2519563 11 prs3 0.2538821 11.1 pany 0.2876505 12.6 binr 0.3857012 16.9 pass 2.2865924 100 10 30000 xxxxxxxxx. ins1 0.0088604 8.7 prs3 0.013247 13.1 prs5 0.0132796 13.1 prs4 0.0133496 13.2 pass 0.0135603 13.4 pany 0.0139156 13.7 binr 0.0284606 28.1 prs2 0.0465389 45.9 prs1 0.1014025 100 10 30000 xxxxx..... ins1 0.0728014 8.7 prs5 0.4326869 51.9 prs4 0.4359396 52.3 pany 0.4537192 54.5 prs3 0.4660354 55.9 prs1 0.5437336 65.3 prs2 0.5491291 65.9 binr 0.638432 76.6 pass 0.8332273 100 10 30000 x......... ins1 0.0882684 1.8 prs4 0.4752613 9.8 prs2 0.5063892 10.4 prs5 0.5120834 10.6 prs3 0.5325967 11 prs1 0.5439077 11.2 pany 0.5661401 11.7 binr 0.7072614 14.6 pass 4.8524088 100 -jn- -- If it works, it's obsolete. -- Eric Marten joel:dot:neely:at:fedex:dot:FIX:PUNCTUATION:com