PHP 7 metaphone function performance

173 views Asked by At

While researching PHP 7 and it's changes and performance, i came across a function which is faster in PHP 5 than in PHP 7: metaphone(). Every other function i tested was considerably faster in PHP 7.

I can't find any information regarding this and it also seems like noone has encountered this, which makes me think the issue is on my end (server config or something). However, as far as i can see the configuration files (php.ini) for both PHP versions are the same (both are x86).

I ran the following script in IIS with both PHP 5 and PHP 7:

<?php
$str = "test";

$count = 1000000;

$time_start = microtime(true);

for ($i=0; $i < $count; $i++) {
    metaphone($str);
}

echo 'Seconds: ' . number_format(microtime(true) - $time_start, 2);

The results:

PHP 5.5.30: 0.97 seconds

PHP 7.0.0: 2.98 seconds

I was hoping someone could test this on their server. If you get the same results, why is PHP 7 in this case slower than PHP 5? If not, what could be the problem on my end?

EDIT:

I just noticed the functions strtoupper() and strtolower are also slower in PHP 7 than in PHP 5.

0

There are 0 answers