PHP code example of christiaanbye / stopwatch

1. Go to this page and download the library: Download christiaanbye/stopwatch 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/ */

    

christiaanbye / stopwatch example snippets


use Stopwatch\Stopwatch;

Stopwatch::start(); // Start the stopwatch

// ... run your tasks here

echo Stopwatch::elapsed(); // Optionally take a peek at the elapsed time

// ... run some more tasks here

Stopwatch::stop(); // Stop the stopwatch once your tasks have ran

echo Stopwatch::elapsed(); // Output the time elapsed between the moment the stopwatch was started and stopped

use Stopwatch\Stopwatch;

Stopwatch::start();

// ... run a first batch of tasks here

Stopwatch::split('1st batch of tasks');

// ... run a second batch of tasks here

Stopwatch::split('2nd batch of tasks');

// ... run a third batch of tasks here

Stopwatch::split('3rd batch of tasks');

// ... optionally run more tasks for which an intermediate time is not necessary

Stopwatch::stop();

print_r(Stopwatch::getSplits()); // Output the time elapsed between the moment the stopwatch was started and stopped