I believe it's true only for non-diacritical operation. However, for
diacritical operation - replace string(*) and position(*), Position(*) is still
faster than replace string.
In order to provide BEST scenario for replace string(*), I use same length of
old and new string for the test (this should be fastest for replace string
operation).
C_TEXT($source;$find;$rtext)
C_LONGINT($count;$time;$rcount)
$count:=100000
$find:=Char(13)
$source:=("this is to test how fast replace string is"+$find)*$count
$time:=0
ES_TestTime (0;->$time)
$rtext:=Replace string($source;$find;$find;*)
ES_TestTime (1;->$time;"total time for replace string:")
$time:=0
ES_TestTime (0;->$time)
$rcount:=ES_Count ($source;$find) //this is simple position operation
ES_TestTime (1;->$time;"total time for position:")
Replace string took 16ms while position took 14ms consistently.
Alan Chan
4D iNug Technical <[email protected]> writes:
>About using Replace string and "big" text (example: count lines in a csv):
><http://livedoc.4d.com/4D-v15-R3-Upgrade-15-R3/Optimizations/Replace-string.300-2674781.en.html>
>
>With 4D v16 compiled, Replace string is now always faster that the loop with
>Position, more specially when diacritical (e=é…). But before it was the wheel
>of death…
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************