|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
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
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:
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) {
        $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


Add a Patch

Pull Requests

Add a Pull Request


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 Mar 03 12:01:28 2024 UTC