|
Set_time_limit (50); $ a = array (1, 2, 3); $ B = array ('A' => 1, 'B' => 2, 'c' => 3); $ c = array ('A' => array (1, 2, 3), 'B' => array (4, 5, 6 ));
$ Time1 = microtime (true );
$ Times = 1000000; #10 w
For ($ I = 1; $ I <= $ times; $ I ++) {$ A = var_export ($ a, true );}
$ Time2 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ B = var_export ($ B, true );}
$ Time3 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ C = var_export ($ c, true );}
$ Time4 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ X = serialize ($ );}
$ Time5 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ Y = serialize ($ B );}
$ Time6 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ Z = serialize ($ c );}
$ Time7 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ O = unserialize ($ X );}
$ Time8 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ P = unserialize ($ Y );}
$ Time9 = microtime (true );
For ($ I = 1; $ I <= $ times; $ I ++) {$ Q = unserialize ($ Z) ;}$ time10 = microtime (true );
$ Var_export_time ['a'] = $ time2-$ time1; $ var_export_time ['B'] = $ time3-$ time2; $ var_export_time ['C'] = $ time4-$ time3;
$ Serialize_time ['a'] = $ time5-$ time4; $ serialize_time ['B'] = $ time6-$ time5; $ serialize_time ['C'] = $ time7-$ time6;
$ Unserialize_time ['a'] = $ time8-$ time7; $ unserialize_time ['B'] = $ time9-$ time8; $ unserialize_time ['C'] = $ time10-$ time9; print_r ($ var_export_time); print_r ($ serialize_time); print_r ($ unserialize_time);?> Output: Array ([a] => 3.3401498794556 [B] => 5.1394801139832 [c] => 8.8483898639679) array ([a] => 1.6063709259033 [B] => 1.7033960819244 [c] => 3.4534389972687) array ([a] => 1.6037359237671 [B] => 1.817803144455 [c] => 3.7992968559265) |