Bug #70363 [Opn]: why mb_* so slow?

From: Date: Thu, 27 Aug 2015 11:57:33 +0000
Subject: Bug #70363 [Opn]: why mb_* so slow?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195551@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70363&edit=1 ID: 70363 Updated by: yohgaki@php.net Reported by: jhdxr@php.net Summary: why mb_* so slow? Status: Open Type: Bug Package: mbstring related Operating System: irrelevent PHP Version: 7.0.0RC1 Block user comment: N Private report: N New Comment: Interesting result. It seems https://3v4l.org/d8IAo is a worst case and mbstring's case insensitive code has performance issue in general. Tried case sensitive https://3v4l.org/ZF3TK version. The result varies, but it seems mb_* functions have improvement margin. I get slower results consistently with current master on my real PC. (I suppose 3v4l is VM or container) If I use $raw = '0123456789abcdefghijklmnopqrstuvwxyzあいうえおかきくけこさしすせそなにぬねのはひふへほまみむめもやいゆえよわをん'; for https://3v4l.org/ZF3TK, case sensitive version mb_strstr() is a little faster. BTW, pcre became a lot faster than 5.6. This is the reason why mb_strstr() is a little faster than pcre version. If anyone could make more generic benchmark script, i.e. benchmark mb_*() functions, it would be helpful. Previous Comments: ------------------------------------------------------------------------ [2015-08-26 16:07:52] jhdxr@php.net Description: ------------ It seems mb_* is much slower than the original string related method, there are lots of data in the user contribution section of the manual (<http://php.net/mb_strlen>, <http://php.net/manual/en/function.mb-strtolower.php>). and today I read a post talk about this topic (<https://v2ex.com/t/216212>), and the author use an regular expression instead of mb_*, which is, and to my surprise, much faster. Here is his code: <https://3v4l.org/d8IAo>. So i'm wondering why mb_* is so slow. Are the users use them in a wrong manner, or our implements has some problem? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70363&edit=1

« previous php.bugs (#195551) next »