php mbstrlen,PHP: mb_strlen - Manual

Just did a little benchmarking (1.000.000 times with lorem ipsum text) on the mbs functions

especially mb_strtolower and mb_strtoupper are really slow (up to 100 times slower compared to normal functions). Other functions are alike-ish, but sometimes up to 5 times slower.

just be cautious when using mb_ functions in high frequented scripts.

# test runs: 1000000

# benchmarking strlen vs. mb_strlen

# normal strlen: 3.6795361042023 ms, average: 3.6795361042023E-6 ms

# mb_strlen: 5.5934538841248 ms, average: 5.5934538841248E-6 ms

ok 1 - mb_strlen is slower than strlen

# mb_strlen is 1.52 slower than strlen

#

#

# benchmarking strpos vs. mb_strpos

# normal strpos: 5.5523281097412 ms, average: 5.5523281097412E-6 ms

# mb_strlen: 31.180974960327 ms, average: 3.1180974960327E-5 ms

ok 2 - mb_strlen is slower than strlen

# mb_strpos is 5.62 slower than strpos

#

#

# benchmarking substr vs. mb_substr

# normal substr: 3.4437320232391 ms, average: 3.4437320232391E-6 ms

# mb_strlen: 3.5374181270599 ms, average: 3.5374181270599E-6 ms

ok 3 - mb_strlen is slower than strlen

# mb_substr is 1.03 slower than substr

#

#

# benchmarking strtolower vs. mb_strtolower

# normal strtolower: 4.446839094162 ms, average: 4.446839094162E-6 ms

# mb_strlen: 193.44901108742 ms, average: 0.00019344901108742 ms

ok 4 - mb_strlen is slower than strlen

# mb_strtolower is 43.5 slower than strtolower

#

#

# benchmarking strtoupper vs. mb_strtoupper

# normal strtoupper: 3.0210740566254 ms, average: 3.0210740566254E-6 ms

# mb_strlen: 340.71775603294 ms, average: 0.00034071775603294 ms

ok 5 - mb_strlen is slower than strlen

# mb_strtoupper is 112.78 slower than strtoupper

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值