PHP code example of tankfairies / benchmark

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

    

tankfairies / benchmark example snippets


$server = new Server();
$details = $server->getDetails();

Array (
    [PHP] => 8.2.16
    [Platform] => Darwin
    [Arch] => arm64
    [Max memory usage] => 128M
    [OPCache status] => disabled
    [OPCache JIT] => disabled/unavailable
    [PCRE JIT] => enabled
    [XDebug extension] => disabled
)

$server = new Server();
$extensions = $server->getInstalledExtensions();

Array
(
    [0] => Core
    [1] => date
    [2] => libxml
    [3] => openssl
    [4] => pcre
    [5] => sqlite3
    [6] => zlib
    [7] => bcmath
    ...

$func = function () {
    rand(1, 100000);
};
 
$benchmark = new Benchmark(new Stopwatch());
$completion = $benchmark
    ->multiplier(200000, 5)
    ->script($func)
    ->run();

Array (
    [1] => 0.1699
    [2] => 0.1642
    [3] => 0.1641
    [4] => 0.1643
    [5] => 0.1645
)