What puts less load on a PHP server: SimpleXML or json_decode?

I'm starting to develop a web application in PHP that I hope will become incredibly popular and make me famous and rich. :-) If that time comes, my decision whether to parse the API's data as XML with SimpleXML or to use json_decode could make a difference in the app's scalability. Does anyone know which of these approaches is more efficient for the server? **Update:** I ran a rudimentary test to see which method was more performant. It appears that `json_decode` is slightly faster executing than `simplexml_load_string`. This isn't terribly conclusive because it doesn't test things like the scalability of concurrent processes. My conclusion is that I will go with SimpleXML for the time being because of its support for XPath expressions.
XML elapsed: 
JSON elapsed: 
Result: XML elapsed: 9.9836 JSON elapsed: 8.3606
Your benchmark isn't terribly realistic. Surely, you'll be manipulating the data in some way, not just loading it? At least try iterating through a few values or something. Load time probably isn't even the bulk of the actual processing you'll end up doing.

以上就是What puts less load on a PHP server: SimpleXML or json_decode?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JSON 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准