php - set_time_limit is not working as expected? -
<?php set_time_limit(4); echo ini_get('max_execution_time'); // give value 4 while ($i<=10) { echo "i=$i "; sleep(1); $i++; }
output: 4i= i=1 i=2 i=3 i=4 i=5 i=6 i=7 i=8 i=9 i=10
expected behaviour: should end execution after 4 seconds.
please explain ?
you should try this, have script sleeps more maximum execution time.
sleep(ini_get('max_execution_time') + 10);
read : under linux, sleeping time ignored, under windows, counts execution time.
this how can computation time , system calls time.
// script start $rustart = getrusage(); // code ... // script end function rutime($ru, $rus, $index) { return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000)) - ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000)); } $ru = getrusage(); echo "this process used " . rutime($ru, $rustart, "utime") . " ms computations\n"; echo "it spent " . rutime($ru, $rustart, "stime") . " ms in system calls\n";
Comments
Post a Comment