how can i show time it took ...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

how can i show time it took ...

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Try looking at the usercomments on the microtime() page @ php.net. There is a good example there that might be of use.
Post Reply