Skip to content

Slower Than Pure PHP #2433

@mailmug

Description

@mailmug

Hi
I tried with the following code. Then I tried using the xdebug. I think it is slower than pure PHP functions.
Please help me.

zep

namespace Utils;

class Greeting
{

    public static function say()
    {
        int item;
        for item in range(0, 100000) {
            string i = "abc";
            string k = str_replace("b", "--", i);
            string z = "abc";
            string m = str_replace("b", "--", z);
            string t = "rrrr";
            string g = str_replace("b", "--", t);
            string q = "rrrr";
            string u = str_replace("b", "--", q);
        }

        echo "okk";
    }

}

PHP CODE

 <?php 

noo();

Utils\Greeting::say();


function noo(){
    for ($ii=0; $ii++; $ii<= 100000) {
        $i = "abc";
        $k = str_replace("b", "--", $i);
        $z = "abc";
        $m = str_replace("b", "--", $z);
        $t = "rrrr";
        $g = str_replace("b", "--", $t);
        $q = "rrrr";
        $u = str_replace("b", "--", $q);
    }
    echo "okk";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions