phper-framework/phper

Shower Than C Extension

arshidkv12 opened this issue · 7 comments

Hi
I tested with xdebug profile option with grind cache.
Functions are slower than c. How to speed up?

What about the data?

cachegrind

PHP code:

for ($i=0; $i < 1000; $i++) { 
        say_hello("sdf"); //rust
        strpos("sdfsf", "d", 1); //c function
}

Rust:

pub fn say_hello(arguments: &mut [ZVal]) -> phper::Result<()> {

    Ok(())
}

Do you build under release?

image

0.18 > 0.11

Why does the Rust function take longer than the C complex O(n) function?

How to optimise it?

PHP is not very friendly to writing extensions in non-C/C++ languages because PHP's source code is heavy and uses macros, while Rust does not support C macros, so some tricks are needed to achieve the desired effect, which can affect performance. However, the purpose of this project is not to improve performance, but simply to use Rust to write PHP extensions, so performance issues are not considered.