Last active
December 19, 2015 23:49
-
-
Save Leask/6037445 to your computer and use it in GitHub Desktop.
Tracking time elapsed for php program in millisecond
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| # Tracking time elapsed for php program in millisecond | |
| # by @leaskh | |
| class runtime { | |
| var $StartTime = 0; | |
| var $StopTime = 0; | |
| function get_microtime() { | |
| list($usec, $sec) = explode(' ', microtime()); | |
| return ((float)$usec + (float)$sec); | |
| } | |
| function start() { | |
| $this->StartTime = $this->get_microtime(); | |
| } | |
| function stop() { | |
| $this->StopTime = $this->get_microtime(); | |
| } | |
| function spent() { | |
| return round(($this->StopTime - $this->StartTime) * 1000, 1); | |
| } | |
| } | |
| $aa=new runtime(); | |
| $aa->start(); | |
| echo file_get_contents("1.txt")."<br>"; | |
| $aa->stop(); | |
| echo $aa->spent(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment