Alix Axel
Alix Axel

Reputation: 154573

In PHP, why is json_encode way slower than serialize?

I don't get it, the data produced by json_encode is much more straightforward than serialize and yet both the JSON encode and decode functions are much more slower than the serialize and unserialize counterparts. Why?

Upvotes: 6

Views: 6360

Answers (1)

Paul Tarjan
Paul Tarjan

Reputation: 50622

json_encode does string parsing and tons of allocs compared to serialize's memcpy

Have fun in the source if you're really in the mood.

Upvotes: 14

Related Questions