Languages
[Edit]
EN

CPU Benchmark - single core speed test with Fibonacci Sequence in PHP

8 points
Created by:
Wiktor-Sribiew
800

In this short article, I would like to show Fibonacci Sequence test that is run on a single core. The test source code was converted from C++ to PHP - check source article.

Example test.php file:

<?php

$a = 0;
$b = 1;

echo "Started!\n";

$t1 = floor(1000 * microtime(true));

for ($i = 0; $i < 10000; ++$i) {
  	for ($j = 0; $j < 1000000; ++$j) {
      	$tmp = $b;
        $b = $a + $b;
        $a = $tmp;
    }
}

$t2 = floor(1000 * microtime(true));
$dt = $t2 - $t1;

echo "Finished!\n";

echo "Result: " . $b . "\n";
echo "Time: " . (0.001 * $dt) . "s\n";

Running with PHP:

php test.php

Example output:

Started!
Finished!
Result: INF
Time: 95.515s

Notes: Result: INF is printed only to prevent against automatic optimization.

 

Used PHP:

PHP 8.2.10-2ubuntu1 (cli) (built: Sep  5 2023 14:37:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.10, Copyright (c) Zend Technologies
   with Zend OPcache v8.2.10-2ubuntu1, Copyright (c), by Zend Technologies

Used OS: Ubuntu 23.10 x64

Used PC:

  • Ryzen 9 5900x
  • DRR 4 (2x 32GB)
  • Samsung SSD M.2 970 EVO (1TB)
  • AMD Radeon RX 6700 XT (12GB RAM)

 

See also

  1. CPU Benchmark - Raspberry PI vs Banana PI - single core speed test with Fibonacci Sequence

  2. CPU Benchmark - single core speed test with Fibonacci Sequence in Java

  3. CPU Benchmark - single core speed test with Fibonacci Sequence in AssemblyScript

  4. CPU Benchmark - single core speed test with Fibonacci Sequence in Dart

  5. CPU Benchmark - single core speed test with Fibonacci Sequence in JavaScript

References

  1. Node.js (nodejs.org) - Homepage
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join