<?php //PHP設定 ini_set('memory_limit', '-1'); ini_set("max_execution_time", "180"); //ディレクトリ設定 $dir = dirname( __FILE__ ); $rs_filename = $dir."/s_data"; $ws_filename = $dir."/s_data"; //初期化 $dl_list = array(); $line_buff = ""; $time = array(); $time[] = microtime(true); if(file_exists($rs_filename)){ $fp = fopen("$rs_filename", "r") or die(); while($line_buff = fgets($fp,1024)){ $line_buff = unserialize(trim($line_buff)); $key = "$line_buff[0]_$line_buff[2]_$line_buff[12]_$line_buff[13]"; $dl_list[$key]['data0'] = $line_buff[0]; $dl_list[$key]['data1'] = $line_buff[1]; $dl_list[$key]['data2'] = $line_buff[2]; $dl_list[$key]['data3'] = $line_buff[3]; $dl_list[$key]['data4'] = $line_buff[4]; $dl_list[$key]['data5'] = $line_buff[5]; $dl_list[$key]['data6'] = $line_buff[6]; $dl_list[$key]['data7'] = $line_buff[7]; $dl_list[$key]['data8'] = $line_buff[8]; $dl_list[$key]['data9'] = $line_buff[9]; $dl_list[$key]['data10'] = $line_buff[10]; $dl_list[$key]['data11'] = $line_buff[11]; $dl_list[$key]['data12'] = $line_buff[12]; $dl_list[$key]['data13'] = $line_buff[13]; } fclose($fp); } $time[] = microtime(true); if (!empty($dl_list)) { $fp = fopen("$ws_filename", "w") or die(); foreach($dl_list AS $val){ $line = array($val['data0'],$val['data1'],$val['data2'],$val['data3'],$val['data4'],$val['data5'],$val['data6'],$val['data7'],$val['data8'],$val['data9'],$val['data10'],$val['data11'],$val['data11'],$val['data12']); fwrite($fp,serialize($line)."\n",1024); } fclose($fp); } $time[] = microtime(true); print "\n serialize time \n"; var_dump($time); print "\n all:".($time[2]-$time[0]); print "\n read:".($time[1]-$time[0]); print "\n write:".($time[2]-$time[1]); ?>