chobie / php-protocolbuffers

PECL ProtocolBuffers
pecl.php.net/package/protocolbuffers
Other
128 stars 38 forks source link

[Feature Request] Optional native types for numeric fields #38

Closed dcelasun closed 6 years ago

dcelasun commented 10 years ago

As you've described in the wiki, all numeric types are converted to string in PHP. I understand why you chose this (PHP doesn't handle scalar primitives very well), but maybe you can provide a config option for this?

For example:

ini_set("protocolbuffers.native_scalars",1);

This way we can have this:

.proto type php type
double double
float double
int32 int
int64 int
uint32 int
uint64 int
sint32 int
sint64 int
fixed32 int
fixed64 int
sfixed32 int
sfixed64 int

This would have better performance on 64bit Linux and OS X systems. Any thoughts?

chobie commented 10 years ago

yap, it's reduce memory and improve performance. I'll add this to my task list.

dcelasun commented 10 years ago

Good to hear, thanks!

chobie commented 10 years ago

for now, prototype works fine on support-native-scalar branch.

simple performance check with example/prefecture.php on my macbook.

#native scalars off (default)
processing time: 5.417232 (0.000542/message)

#native scalars on
processing time: 4.771613 (0.000477/message)

I'll brush this branch up on this week.

chobie commented 10 years ago

Oops, Travis failed. I'll Check it when I back home

dcelasun commented 10 years ago

native scalars off (default)

processing time: 5.417232 (0.000542/message)

native scalars on

processing time: 4.771613 (0.000477/message)

Looking good, that's nearly a 12% improvement! I'll wait until the Travis build passes and run my own tests.

mishak87 commented 10 years ago

:+1: Especially for enums it would make sense.

chobie commented 10 years ago

guys, sorry for late response.

My wife will begin forced to stay in hospital in this week. I don't have time right now, but I'm going to release this improvement in this month :) thanks

dcelasun commented 10 years ago

No worries @chobie, hope your wife feels better soon :)

mishak87 commented 10 years ago

@chobie hope she will get better