Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library

 

Category: PHP Codes Library >> PHP Tools >> Page Function Speed Tester


Code Snippet </> Info


Snippet Name: Page Function Speed Tester

Description: If you think you have a time-consuming script, use these functions to find out how long your page needs to load. Just call the first function first in the script, and the last function last, and it will generate a report on elapsed time in between functions.

Note: You might use this to try out if you can optimize your script to make it faster.

Author: Josh Petrovich

Last Modified: 2019-12-15 01:53:45

Language: php

Highlight Mode: html

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor


  About Copying
Copied To Clipboard!

<? $timekeeper = array(); $timereport = array(); function start_track($item, $timekeeper) { $timeStart=gettimeofday(); $timeStart_uS=$timeStart["usec"]; $timeStart_S=$timeStart["sec"]; $item1 = $item . "_usec"; $item2 = $item . "_sec"; $timekeeper[$item1] = $timeStart_uS; $timekeeper[$item2] = $timeStart_S; return $timekeeper; } function end_track($item, $timekeeper, $timereport) { $timeEnd=gettimeofday(); $timeEnd_uS=$timeEnd["usec"]; $timeEnd_S=$timeEnd["sec"]; $item1 = $item . "_usec"; $item2 = $item . "_sec"; $start_uS = $timekeeper[$item1]; $start_S = $timekeeper[$item2]; $ExecTime_S = ($timeEnd_S+($timeEnd_uS/1000000))-($start_S+($start_uS/1000000)); $timereport[$item] = $ExecTime_S; return $timereport; } function time_report($timereport) { while(list($key, $time) = each($timereport)) { print "$key - $time sec.<br>n"; } } // use these lines to perform the function calls. Make sure that you // use the name name for the start and stop functions or it won't work // make as many calls as you want wherever you want then use time_report // to list all the different times $timekeeper = start_track("stringofyourchoice", $timekeeper); $timereport = end_track("stringofyourchoice", $timekeeper, $timereport); // when all is said and done, call this after last end_track has been called time_report($timereport); // This script found at: https://sanpbuilder.com Free Public Codes Library ?>


[ Snippet Options ]

 

© 2002 -  Snap Builder Public Codes Library