Source for file Timing.php
Documentation is available at Timing.php
* Timing functions for the run.
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
namespace PHP_CodeSniffer\Util;
* The start time of the run.
private static $startTime;
* Used to make sure we only print the run time once per run.
private static $printed = false;
* Start recording time for the run.
public static function startTiming ()
self ::$startTime = microtime (true );
* Print information about the run.
* @param boolean $force If TRUE, prints the output even if it has
* already been printed during the run.
public static function printRunTime ($force=false )
if ($force === false && self ::$printed === true ) {
if (self ::$startTime === null ) {
// Timing was never started.
$time = ((microtime(true ) - self ::$startTime) * 1000 );
$mins = floor ($time / 60000 );
$secs = round((($time % 60000 ) / 1000 ), 2 );
} else if ($time > 1000 ) {
$time = round(($time / 1000 ), 2 ). ' secs';
$time = round($time). 'ms';
echo " Time: $time; Memory: $mem".PHP_EOL.PHP_EOL;
Documentation generated on Mon, 11 Mar 2019 15:27:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|