phper-framework / phper

The framework that allows us to write PHP extensions using pure and safe Rust whenever possible.
Other
265 stars 16 forks source link

Shower Than C Extension #149

Open arshidkv12 opened 6 months ago

arshidkv12 commented 6 months ago

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

jmjoy commented 6 months ago

What about the data?

arshidkv12 commented 6 months ago

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(())
}
jmjoy commented 6 months ago

Do you build under release?

arshidkv12 commented 6 months ago

Yes

On Thu, 25 Jan, 2024, 8:40 am jmjoy, @.***> wrote:

Do you build under release?

— Reply to this email directly, view it on GitHub https://github.com/phper-framework/phper/issues/149#issuecomment-1909271654, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT5Y5KK4RFWKLXKBRSRK23YQHEI7AVCNFSM6AAAAABCIK47M2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBZGI3TCNRVGQ . You are receiving this because you authored the thread.Message ID: @.***>

jmjoy commented 6 months ago

image

arshidkv12 commented 6 months ago

image

0.18 > 0.11

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

How to optimise it?