Gruzin Posted January 9, 2007 Share Posted January 9, 2007 Hi guys,How can I write a code for mysql query wich will determine the query time? I mean something like this:[code]Query took 0.0005 sec - from phpmyadmin[/code]Thanks for reading,George Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 9, 2007 Share Posted January 9, 2007 There may be a built in function that I'm not aware of, but barring that you simple need to save a timestamp before and after the query and subtract. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 $start = time();//Do your stuff here$end = time();$total = $end-$start; // number of seconds. Quote Link to comment Share on other sites More sharing options...
Gruzin Posted January 9, 2007 Author Share Posted January 9, 2007 [quote author=jesirose link=topic=121663.msg500691#msg500691 date=1168361671]$start = time();//Do your stuff here$end = time();$total = $end-$start; // number of seconds.[/quote][code]<?php$start = time();require ('rolex/config.php');$sql = mysql_query("SELECT * FROM archives");$end = time();$total = $end-$start; // number of seconds.echo $total;?>[/code]It displays 0....Thanks for your replies,George Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 9, 2007 Share Posted January 9, 2007 time() only evaluates down to whole seconds. You query is probably taking less than a second to run. Use microtime() instead for milliseconds. Quote Link to comment Share on other sites More sharing options...
Gruzin Posted January 9, 2007 Author Share Posted January 9, 2007 Thanks! it works, but when I refresh the page it displays completely different time...Regards,George Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 9, 2007 Share Posted January 9, 2007 It's not goingto be the same every time - especially since we are talking microseconds. Quote Link to comment Share on other sites More sharing options...
Gruzin Posted January 9, 2007 Author Share Posted January 9, 2007 Ok, thank you very much mjdamato for your help ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.