Use this Small code to check the execution time of your script.
<?php
// Write this line at the top of script
$start = (float) array_sum(explode(‘ ‘,microtime()));
/*
your code here
*/
// Write these lines at the bottom of script
$end = (float) array_sum(explode(‘ ‘,microtime()));
echo sprintf(“%.4f”, ($end-$start));
?>
If you want to increase the execution time limit then use these:
1. set_time_limit(int $seconds)
(See it – will not work in Safe Mode)
2. ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes
(See it – ini_set will not work in Safe Mode)
3. Via .htaccess
php_value max_execution_time 90
4. Also set php.ini - This maximum execution time limit is set inside the php.ini file like this.
max_execution_time = 30; Maximum execution time of each script, in seconds
For Example
<!-- this code at the top of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
;?>
<!-- this code at the bottom of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
;?>
output
This page was created in 0.0027 seconds.
<?php
// Write this line at the top of script
$start = (float) array_sum(explode(‘ ‘,microtime()));
/*
your code here
*/
// Write these lines at the bottom of script
$end = (float) array_sum(explode(‘ ‘,microtime()));
echo sprintf(“%.4f”, ($end-$start));
?>
If you want to increase the execution time limit then use these:
1. set_time_limit(int $seconds)
(See it – will not work in Safe Mode)
2. ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes
(See it – ini_set will not work in Safe Mode)
3. Via .htaccess
php_value max_execution_time 90
4. Also set php.ini - This maximum execution time limit is set inside the php.ini file like this.
max_execution_time = 30; Maximum execution time of each script, in seconds
For Example
<!-- this code at the top of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
;?>
<!-- this code at the bottom of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
;?>
output
This page was created in 0.0027 seconds.
No comments:
Post a Comment