ANN: Remove double spaces--plugin

Jim Ault JimAultWins at yahoo.com
Mon Dec 5 05:58:46 EST 2005


Interesting, Mark.  Good example. [see code below in original post]
So 20 milliseconds   div  10,000 space runs
= 2.0 x 10^-2  seconds  div  1.0 x 10^4  =  2.0 x 10^-6 seconds

0.000002 seconds -->one Replace of a space run
0.000020 seconds -->one ReplaceText of a space run

0.002 milliseconds -->one Replace of a space run
0.020 milliseconds -->one ReplaceText of a space run

2 microseconds -->one Replace of a space run
20 microseconds -->one ReplaceText of a space run

Using your base ("xxxx yyyzzzz") 12 chars*10,000 = 120,000 chars
Adding spaces avg ("     ") 5 chars *10,000 = 50,000 spaces
Total 170,000 characters in fld tText

Approximation:
A text block containing 1700 characters, 50% of which were spaces, would
take about 1 millionth of a second to use ReplaceText pattern searching,
which is 10 times slower than the Replace technique you programmed.

This is sooo much better than the old days, trying to find XCMDs to boost
performance!!!!  Who needs a beach ball cursor these days.

Jim Ault
Las Vegas


On 12/4/05 9:54 PM, "Mark Smith" <mark at maseurope.net> wrote:

> 'The replaceText function is not as fast as the Replace command'
> 
> That is certainly true.
> 
> in the code below, using the more complicated (in terms of code)
> replace function takes 20ish milliseconds, whereas the replaceText
> version (commented out) takes about 200.
> 
> on mouseUp
>    repeat 10000 -- set up some text with varying numbers of spaces
>      add 1 to c
>      put "xxxx yyy" into tLine
>      repeat random(10)
>        put space after tLine
>      end repeat
>      put "zzzz." after tLine
>      put tLine & cr after tList
>    end repeat
>    put tList into fld 1
> 
>    put fld 1 into tText
> 
>    put the millisecs into st
>    repeat until doubleSpace = 0
>      put offset("  ",tText) into doubleSpace
>      if doubleSpace > 0 then replace "  " with " " in tText
>    end repeat
>    put the millisecs - st
>    put tText into fld 1
> 
> --  put the millisecs into st
> --  put replaceText(tText," +"," ") into tText
> --  put the millisecs - st
> --  put tText into fld 1
> 
> end mouseUp
> 
> Mark
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list