public static function encode($data) { if (self::$avFlag) { return av_encode($data); } else { return CUtils::encode($data); } }
<?php $str1 = file_get_contents('conn_anyvalue2.bin'); $str2 = file_get_contents('conn_json.txt'); $str3 = file_get_contents('conn_ig.bin'); echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $obj = json_decode($str2, true); } echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $obj = av_decode($str1); } echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $obj = igbinary_unserialize($str3); } echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $str = av_encode($obj); } echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $str = igbinary_serialize($obj); } echo microtime(true) . "\n"; for ($i = 0; $i < 100000; $i++) { $str = json_encode($obj); } echo microtime(true) . "\n";
<?php class A { } $obj['abc'] = 'dasdasdsa'; $obj['bcd'] = 10000; //$obj['a']=new A(); $obj['name'] = "sssssss"; $obj['urls'] = array('http://www.baidu.com', 'http://www.qq.com'); $obj['info']['age'] = 19; $obj['info']['name'] = 'helloworld'; $obj['info']['price'] = 1.5555; var_dump($str = av_encode($obj)); var_dump(av_decode($str));