php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77461 perfomance slowdown
Submitted: 2019-01-15 13:58 UTC Modified: 2019-01-15 14:18 UTC
From: legale dot legale at gmail dot com Assigned:
Status: Closed Package: mbstring related
PHP Version: 7.3.1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: legale dot legale at gmail dot com
New email:
PHP Version: OS:

 

 [2019-01-15 13:58 UTC] legale dot legale at gmail dot com
Description:
------------
There is a problem with mbfl library functions. UTF-16, UTF-16BE, UTF-16LE encodings are parsed by the slow path (variable width multibyte encodings). 


Test script:
---------------
<?php
function bmark()
{
    $args = func_get_args();
    $len = count($args);

    if ($len < 3) {
        trigger_error("At least 3 args expected. Only $len given.", 256);
        return false;
    }

    $cnt = array_shift($args);
    $fun = array_shift($args);

    $start = microtime(true);
    $i = 0;
    while ($i < $cnt) {
        $i++;
        $res = call_user_func_array($fun, $args);
    }
    $end = microtime(true) - $start;
    return $end;
}

$i = 1000;
$str32 = mb_convert_encoding(str_repeat("строка", $i), "UTF-32", "UTF-8");
$str16 = mb_convert_encoding(str_repeat("строка", $i), "UTF-16", "UTF-8");

echo "str16: " . bmark($i, "mb_substr", $str16, 0, null, "UTF-16") . PHP_EOL;
echo "str32: " . bmark($i, "mb_substr", $str32, 0, null, "UTF-32") . PHP_EOL;

?>

Expected result:
----------------
UTF-16 and UTF-32 parsing speed should be mostly the same. 

Actual result:
--------------
str16: 0.13957190513611
str32: 0.026632070541382

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-15 14:18 UTC] legale dot legale at gmail dot com
-Status: Open +Status: Closed
 [2019-01-15 14:18 UTC] legale dot legale at gmail dot com
Wrong report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC