Php 如何提高JSON的性能
我有一个使用PHP生成的JSON对象,格式如下Php 如何提高JSON的性能,php,json,Php,Json,我有一个使用PHP生成的JSON对象,格式如下 [{ "timestamp": "12\/16\/2013 0:00", "curr_property": "7211", "curr_property_cost": "123", "day_property": "48", "day_property_cost": "281", "curr_solar_generating": "4958", "curr_solar_export": "0"
[{
"timestamp": "12\/16\/2013 0:00",
"curr_property": "7211",
"curr_property_cost": "123",
"day_property": "48",
"day_property_cost": "281",
"curr_solar_generating": "4958",
"curr_solar_export": "0",
"day_solar_generated": "33",
"day_solar_export": "0",
"curr_chan1": "1964",
"curr_chan2": "4958",
"curr_chan3": "289",
"day_chan1": "13",
"day_chan2": "33",
"day_chan3": "1"
},
{
"timestamp": "12\/16\/2013 0:00",
"curr_property": "7211",
"curr_property_cost": "123",
"day_property": "48",
"day_property_cost": "281",
"curr_solar_generating": "4958",
"curr_solar_export": "0",
"day_solar_generated": "33",
"day_solar_export": "0",
"curr_chan1": "1964",
"curr_chan2": "4958",
"curr_chan3": "289",
"day_chan1": "13",
"day_chan2": "33",
"day_chan3": "1"
}]
将格式更改为
[{
"timestamp": ["12\/16\/2013 0:00", "12\/16\/2013 0:00", ..........],
"curr_property": ["7211","32432",...........],
"day_chan3": ["1","2","3"............]
}
提高性能?我是JSON新手,因此请向我建议提高应用程序速度的方法,因为JSON数据量非常大,接近40 MB,而且还在不断增长。您想知道如何提高应用程序的速度吗?然后使用XDebug。XDebug将告诉您代码的哪些部分比较慢。不要只是随便猜测什么东西慢。为什么不自己做一个小的性能测试呢?提高性能的方法是不要让它在使用站点上“不断增长”。相反,提供仅在需要时使用数据的方法,或者提供流使用的方法。使用deflate压缩,我希望两种格式的导线尺寸“相似”。(同时,使用JSON数字表示..数字。)我猜一定有人已经尝试过了,如果没有人回答,我就不得不这么做。@user2864740谢谢,这似乎是个非常好的主意。我也将对此进行研究。感谢@Andy Lester,我的应用程序在很大程度上依赖于将CSV处理为JSON数据,因此我的想法是减少JSON数据的大小将有助于提高性能,但user2845740的建议非常好,感谢您告知此工具