Page 1 of 1
how can i show time it took ...
Posted: Sun Jan 16, 2005 1:19 pm
by HormonX
I am not sure how to show time it took to run a query. Is there a function in php or mysql statement to do that ?
thank you
Greg
Posted: Sun Jan 16, 2005 2:08 pm
by infolock
Best way would be to do something along these lines of steps..
a) assign a variable the current time along with miliseconds.
b) issue the query
c) assign a second variable with the new time after the query is finished.
d) subtract a from c and print out total seconds.
Posted: Sun Jan 16, 2005 2:57 pm
by HormonX
this might be the best way of going about this ... do you know where i can look at the example?
is there anyother way of doing it ?
Greg
Posted: Sun Jan 16, 2005 3:12 pm
by infolock
using the php function time() would be what you are needing...
http://us2.php.net/time
I can write it for you, but you aren't learning that way

Just play around with the time function and see what you can do. If you need help with the code, post what you got and we can help you from there.
Posted: Sun Jan 16, 2005 4:16 pm
by HormonX
i wouldn't want to use you to write it for me

... am just not sure how to get the time the query is being initiated and then retrieve it and do necesary math to calculate time difference.
Greg
Posted: Sun Jan 16, 2005 5:07 pm
by JAM
Try looking at the usercomments on the microtime() page @ php.net. There is a good example there that might be of use.