PHP code example of smuuf / phpcb

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

    

smuuf / phpcb example snippets




 = new \Smuuf\Phpcb\PhpBenchmark;

const COUNT = 100;

$bench->addBench(function() {
	for ($i = 1; $i <= COUNT; $i++) {}
});

$bench->addBench(function() {
	for ($i = COUNT; $i > 0; $i--) {}
});

$bench->addBench(function() {
	for ($i = COUNT; $i--;) {}
});

$bench->addBench(function() {
	for ($i = -COUNT; $i++;) {}
});

$bench->run();

█ PHP Code Benchmark (phpcb)
█ PHP 7.4.27

Engine used: Chaotic Engine
Total time: 1.3220 sec
Iterations: 1 000 000

██ 2. Score: 100.00, 0.2660 sec
┌
│ $bench->addBench(function() {
│       for ($i = COUNT; $i > 0; $i--) {}
│ });
└

██ 1. Score: 86.54, 0.3074 sec, 1.16x slower
┌
│ $bench->addBench(function() {
│       for ($i = 1; $i <= COUNT; $i++) {}
│ });
└

██ 4. Score: 71.13, 0.3740 sec, 1.41x slower
┌
│ $bench->addBench(function() {
│       for ($i = -COUNT; $i++;) {}
│ });
└

██ 3. Score: 71.02, 0.3746 sec, 1.41x slower
┌
│ $bench->addBench(function() {
│       for ($i = COUNT; $i--;) {}
│ });
└
bash
$ php ./mymicrobench.php