[dokuwiki] Re: darcs changes 2009-07-25

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 25 Jul 2009 11:27:21 +0100


On 25 Jul 2009, at 03:00, Andreas Gohr wrote:
---------------------------------------------------------------------
Fri Jul 24 10:40:09 CEST 2009 Andreas Haerter <netzmeister[at]andreas-haerter.de>
 * Much faster version of utf8_isASCII()
 Ignore-this: 1adbc2b33e76b3a76e650c340e9644e6
This version uses a non-capturing regular expression instead of looping through
 all characters of the string.


Do we have any tests or evidence to show that the new code is faster than the old code?

My 5 minute check shows the old code is considerably faster.

When the utf8 character is found, its the last character in the string. The floats are the duration in seconds to run the function loop times with the string. The code I used is at http://dokuwiki.pastebin.com/m6d36a1e7

Array
(
    [loop] => 100000
    [str length] => 3506
    [utf8 found] =>
    [utf8_isASCII - ord() loop] => 0.18101096153259
    [utf8_isASCII - preg] => 0.25358915328979
)
Array
(
    [loop] => 100000
    [str length] => 46
    [utf8 found] =>
    [utf8_isASCII - ord() loop] => 0.18088603019714
    [utf8_isASCII - preg] => 0.252445936203
)
Array
(
    [loop] => 100000
    [str length] => 49
    [utf8 found] => 1
    [utf8_isASCII - ord() loop] => 0.18106913566589
    [utf8_isASCII - preg] => 0.2602379322052
)

- Chris
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: