Hi Juan,

On Wed, Jun 24, 2015 at 12:05 PM, Juan Basso <jrba...@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
yohg...@ohgaki.net

Reply via email to