Open HallofFamer opened 9 years ago
The performance (at least with the current implementation) will be worse than directly calling a native function, primarily because we have to go through an extra indirection function to handle the extra argument. But it should not be magnitudes slower either.
I see, thanks for the explanation Nikic. And how does it compare to using a wrapper object? Lets say I have an Array object or String object, which stores an array or string literal as its property internally. Will scalar objects be faster than wrapper objects?
Yes, scalar objects will be more efficient than wrapper objects because you don't need to actually instantiate objects.
I see, thanks for the explanation. So its possible to use this in production already, correct? I am also working on an extension called Scalar Classes, which provide implementation for Scalar Objects but its written in C as PHP extension, so I think it should be even faster this way.
And if I may ask, have you looked at the other issue I posted(Can you bring this to PHP RFC)? Any plan for starting an RFC for this? Or maybe bring it to PECL first?
Did anyone try that with userland implementation of scalar objects? I am trying to create a scalar classes extension in C with Boolean, Int, Float, Null and String, I suppose it will be even faster than userland implementation. I wonder if the speed of using scalar objects such as 2->abs(), and "my string"->toUpper() will be on par with just calling native function abs(2) and strtoupper("my string"). Or at least, it will not be magnitudes slower like if I wrap primitives in classes?