SA-MP Forums Archive
(PHP) Page created in 'x' seconds with 'y' queries. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: (PHP) Page created in 'x' seconds with 'y' queries. (/showthread.php?tid=374257)



(PHP) Page created in 'x' seconds with 'y' queries. - nGen.SoNNy - 02.09.2012

Hello guys! I need some help to include this in my website but i have no idea about how to make this:
PHP код:
Page created in 'x' seconds with 'y' queries
REP++;


Re: (PHP) Page created in 'x' seconds with 'y' queries. - Your:RP - 02.09.2012

Huh? You aren't explaining it enough.

What exactly is it you want to include on the website?


Re: (PHP) Page created in 'x' seconds with 'y' queries. - nGen.SoNNy - 02.09.2012

At the buttom of my website i want to include a script that shows me how much time take to create the curent page and how much query!


AW: (PHP) Page created in 'x' seconds with 'y' queries. - Johndaonee - 02.09.2012

A message that shows the visitor how fast the page was loaded I guess


Re: (PHP) Page created in 'x' seconds with 'y' queries. - ReVo_ - 02.09.2012

Try to be a bit more precise


Re: (PHP) Page created in 'x' seconds with 'y' queries. - ReVo_ - 02.09.2012

PHP код:
$start time();

// code

echo "Time loaded in:" . (time()-$start); 
For querys mhm.. idk how to know how much query runned but you can do something like:

PHP код:

mysql_query
( .. );
$querys ++;

end code:

echo 
"Querys: " $querys



Re: (PHP) Page created in 'x' seconds with 'y' queries. - Your:RP - 02.09.2012

Anyway, how is this remotely connected to pawn script?


Re: (PHP) Page created in 'x' seconds with 'y' queries. - nGen.SoNNy - 02.09.2012

where should i put that
PHP код:
$start time(); 
?


Re: (PHP) Page created in 'x' seconds with 'y' queries. - mkr - 02.09.2012

At the top of your script, put something like this:

Код:
<?php
	$pageexec_time = microtime(true);		// this will return a floating point Unix timestamp with milliseconds included
	$pageexec_queries = 0;
?>
Then for every one of your queries, increment $pageexec_query like this:
Код:
<?php
	mysqli_query($whatever);
	$pageexec_queries++;
?>
Then at the end of your script, put this bit that reports the execution time and the number of queries used:
Код:
<?php
	echo "<p>Page created in ".(microtime(true)-$pageexec_time)." seconds with $pageexec_queries queries.</p>";
?>



Re: (PHP) Page created in 'x' seconds with 'y' queries. - nGen.SoNNy - 02.09.2012

Result: Page created in 0.00038003921508789 seconds with 1 queries.

How can i minimize the number of digits?