I have example below:
// start time
// make mysql query here
for($i = 0; $i < 10; $i++) // for loop
{
// make dig lookup here
if (domain found){
// Update database
}
}
if (time <= 60 sec)// check current finishing time and compare
{
// make my sql update
}
What I want to do is to check how many seconds the time is after the loop and then if the time taken to finish the for loop is less than 60 sec than run the mysql update. If you don't understand me, you can ask me. I'm sorry for the language. I'm not good with English and I wasn't sure if this thing is possible to do. Thank you.
$time1 = time();
for($i = 0; $i < 10; $i++){ // for loop
// make dig lookup here
}
$time2 = time();
if (($time2 - $time1) < 60){
// make my sql update
}
$start = microtime(true);
[...]
$end = microtime(true);
if (($end - $start) < 60) {
}
First, remember to close your connections.
Anyway, the microtime
solution given by @webbiedave is good, but i've had some weird experiences (negative results mostly).
The Advanced PHP Debugger has gave me better results.
How to use it:
1.First line of your script
<?php
// In the First line of your script
apd_set_pprof_trace();
// The rest of your code here
?>
2.Run the script. This file will be generated: apd.dumpdir/pprof_pid.ext
3.Display the data with pprofp
bash-2.05b$ pprofp -R /tmp/pprof.22141.0