Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt
| From: | Jim Winstead | Date: | Sat, 05 Jan 2002 21:45:10 +0000 |
| Subject: | Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-75974@lists.php.net to get a copy of this message | ||
the test using the old code finally finished. it took almost 14 minutes.
(the new code takes 0.8 seconds. i'd say it's an improvement.)
jim
On Sat, Jan 05, 2002 at 11:02:51PM +0200, Andi Gutmans wrote:
> Nice!
>
> At 08:46 PM 1/5/2002 +0000, jim winstead wrote:
> >jimw Sat Jan 5 15:46:45 2002 EDT
> >
> > Modified files:
> > /php4/ext/standard string.c
> > /php4/ext/standard/tests/strings wordwrap.phpt
> > Log:
> > New memcpy()-based wordwrap() implementation. The simple case
> > (single-character break, no forced break) appears to be about 60%
> > faster, and there's simply no comparison for non-simple cases with
> > non-trivial amounts of text. The old algorithm was O(n^2) (with an
> > unfortunately large constant factor) because of the use of strncat(),
> > the new one is O(n). Added some more tests, too.
> > @ - Made wordwrap() significantly faster. (Jim)
> > # test case: $t = join('',file('ChangeLog')); $w =
> > wordwrap($t,10,"\n",1);
> > # new code completes in less than a second. i'm still waiting for the
> > # old code to finish.
> >
> >
>