Re: Optimizing php_html_entities()

From: Date: Wed, 24 Jun 2015 03:20:06 +0000
Subject: Re: Optimizing php_html_entities()
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-86833@lists.php.net to get a copy of this message
Hi Juan, On Wed, Jun 24, 2015 at 12:05 PM, Juan Basso <jrbasso@gmail.com> wrote: > Did you test the performance impact on strings? Since you changed how it > works the impact can be positive and maybe worth to make the method more > broad. It's a bit slower (~3%) for 'abc' as input string. If I remove redundant type check(convert_to_string), it's better though. ~3% seems too large for 2 additional if statements - parameter type check. I'll look into. [yohgaki@dev github-php-src]$ cat b.php <?php const LOOP=100000000; $start = microtime(true); for ($i = 0; $i < LOOP; $i++) { } $loop_time = microtime(true) - $start; $start = microtime(true); for ($i = 0; $i < LOOP; $i++) { htmlspecialchars('abc'); } echo 'Time: '.(microtime(true) - $start - $loop_time)."\n"; [yohgaki@dev github-php-src]$ ./php.old b.php Time: 4.4925589561462 [yohgaki@dev github-php-src]$ ./php.old b.php Time: 4.4821939468384 [yohgaki@dev github-php-src]$ ./php.new b.php Time: 4.5892491340637 [yohgaki@dev github-php-src]$ ./php.new b.php Time: 4.6097931861877 -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#86833) next »