PHP code example of janiaje / benchmark

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

    

janiaje / benchmark example snippets


Janiaje\Benchmark\Provider::class,

benchmark()

benchmark()->checkpoint();

$elapsedTime = benchmark()->getElapsedTime();

$ramUsage = benchmark()->getPeakRamUsage();

$checkpoints = benchmark()->getCheckpoints();

benchmark()->dump();

benchmark()->dd();

benchmark()->setOutputFormat(ArrayFormat::class);
benchmark()->setOutputFormat(JsonFormat::class);

benchmark()->checkpoint("After expensive calculation");

benchmark()->checkpointWithGroup("File generation");

benchmark()->getCheckpointsByGroup("File generation");

benchmark()->deleteAllCheckpoints();

benchmark()->deleteCheckpoints("File generation");

$checkpoint = benchmark()->checkpoint();
benchmark()->deleteCheckpoint($checkpoint->getId();

$benchmark1 = new Benchmark;
$benchmark1->checkpoint();
$benchmark1->getAllCheckpoints();

$benchmark2 = new Benchmark;
$benchmark2->checkpoint();
$benchmark2->getAllCheckpoints();
text
Collection {#275 ▼
  #items: array:2 [▼
    0 => array:6 [▼
      "id" => "#1"
      "name" => null
      "group" => null
      "time" => Carbon @1521101210 {#272 ▶}
      "timeDifference" => null
      "ram" => 6291456
      "queries" => []
    ]
    1 => array:6 [▼
      "id" => "#2"
      "name" => null
      "group" => null
      "time" => Carbon @1521101211 {#270 ▶}
      "timeDifference" => DateInterval {#277 ▶}
      "ram" => 6291456
      "queries" => array:1 [▼
        0 => {#279 ▼
          +"query": "SELECT * FROM users WHERE email = ?"
          +"bindings": array:1 [▼
            0 => "[email protected]"
          ]
          +"time": 1.15
        }
      ]
    ]
  ]
}
text
    1 => array:6 [▼
      "id" => "#2"
      "name" => "After expensive calculation"
      "group" => null
      "time" => Carbon @1521101211 {#270 ▶}