Changeset 17722 for trunk/FACT++/www/viewer
- Timestamp:
- 04/29/14 11:37:14 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/viewer/index.php
r17718 r17722 119 119 return; 120 120 121 $ data= fread($handle, $size*$count);122 $data = unpack($format.$count, $data);121 $binary = fread($handle, $size*$count); 122 $data = unpack($format.$count, $binary); 123 123 124 124 return $count==1 ? $data[1] : $data; 125 125 } 126 126 127 // This is to allow for events of ROI=1024 128 ini_set("memory_limit", "384M"); 127 //ini_set("memory_limit", "64M"); 129 128 130 129 //define('E_FATAL', E_ERROR | E_USER_ERROR | E_PARSE | E_CORE_ERROR | … … 162 161 // Read the data and copy it from an associative array to an Array 163 162 // (this is just nicer and seems more logical) 163 //$data = array(); 164 $binary = array(); 165 for ($i=0; $i<$evt['numPix']; $i++) 166 $binary[$i] = fread($file, 2*$evt['numRoi']); 167 /* 164 168 $data = array(); 165 169 for ($i=0; $i<$evt['numPix']; $i++) 166 170 { 167 //$data[$i] = get($file, "s", $evt['numRoi']);168 171 $var = get($file, "s", $evt['numRoi']); 169 170 172 $data[$i] = array(); 171 173 for ($j=0; $j<$evt['numRoi']; $j++) 172 174 $data[$i][$j] = $var[$j+1]*0.48828125; // dac -> mV 173 } 175 }*/ 174 176 } 175 177 … … 229 231 230 232 // This is much faster than the variables option in the constructor 231 $v8->data = $data; 232 $v8->event = $evt; 233 $v8->clone = function($data) { return $data; }; 233 234 $roi = $evt['numRoi']; 235 236 //$v8->data = $data; 237 //$v8->test = array();; 238 //$v8->data = array(); 239 $v8->event = $evt; 240 $v8->clone = function($data) { return $data; }; 241 $v8->unpack = function($i) 242 { 243 global $binary, $roi; 244 $u = unpack("s".$roi, $binary[$i]); 245 $arr = array(); 246 for ($i=0; $i<$roi; $i++) 247 $arr[$i] = $u[$i+1]*0.48828125; 248 return $arr; 249 }; 250 251 // 10, 445, 91.75 MiB 252 // 376, 720, 91.75 MiB 234 253 235 254 $rc['startJs'] = microtime(true); 255 $rc['timeJS'] = array(); 236 256 237 257 // Buffer output from javascript … … 240 260 try 241 261 { 262 263 // We unpack the data pixel by pixel and copy the array directly to the 264 // Javasscript array. This significantly decreases memory usage because 265 // we need only one of the super memory hungry php arrays of size ROI 266 // instead of 1440. 267 $JS = "$.data = new Array($.event.numPix); for (var i=0; i<$.event.numPix; i++) $.data[i] = $.unpack(i);"; 268 $v8->executeString($JS, 'internal'); 269 270 $rc['timeJs'][0] = (microtime(true) - $rc['startJs']); 271 242 272 $JS = "function proc(pixel){\n".$_POST['source1']."\n};proc(".$pixel.");"; 243 273 $rc['waveform'] = $v8->executeString($JS, 'proc'); 274 275 $rc['timeJs'][1] = (microtime(true) - $rc['startJs']); 244 276 245 277 if (isset($_POST['source2'])) … … 270 302 $now = microtime(true); 271 303 272 $rc['timeJs'] = ($now - $rc['startJs']);304 $rc['timeJs'][2] = ($now - $rc['startJs']); 273 305 } 274 306 275 307 $rc['timePhp'] = ($now - $rc['startPhp']); 308 309 $rc['memory'] = memory_get_peak_usage(true)/1024/1024; 276 310 277 311 // Output result as JSON object
Note:
See TracChangeset
for help on using the changeset viewer.