PHP code example of PHPUnit / PHP-Timer timing

1. Go to this page and download the library: Download phpunit/php-timer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

PHPUnit / PHP-Timer timing example snippets


// Basic Timing
use SebastianBergmann\Timer\Timer;

Timer::start();

$time = Timer::stop();
var_dump($time);

print Timer::secondsToTimeString($time);

/*
The code above yields the output below:

double(1.0967254638672E-5)
0 ms 
*/

// Resource Consumption Since PHP Startup

print Timer::resourceUsage();

/*
The code above yields the output below:

Time: 0 ms, Memory: 0.50MB
*/