Skip to content

Instantly share code, notes, and snippets.

@Leask
Last active December 19, 2015 23:49
Show Gist options
  • Select an option

  • Save Leask/6037445 to your computer and use it in GitHub Desktop.

Select an option

Save Leask/6037445 to your computer and use it in GitHub Desktop.
Tracking time elapsed for php program in millisecond
<?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