3v4l.org

run code in 300+ PHP versions simultaneously
<?php function acceptOne($a) {}; final class Foo { public $notTyped; public int $typed; } $benchFx = function (string $msg, \Closure $fx) { $times = []; for ($i = 0; $i < 10; $i++) { $t = microtime(true); $fx(); $t = microtime(true) - $t; $times[] = $t; } $bestTime = min($times); echo $msg . ': ' . round($bestTime * 1000, 2) . " ms\n"; }; $benchFx('assign not typed', function () { $foo = new Foo(); for ($i = 0; $i < 100_000; $i++) { $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; } acceptOne($foo); }); $benchFx('assign typed', function () { $foo = new Foo(); for ($i = 0; $i < 100_000; $i++) { $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; } acceptOne($foo); });
Output for 8.4.4
assign not typed: 1.91 ms assign typed: 2.77 ms
Output for 8.3.12
assign not typed: 2.02 ms assign typed: 2.78 ms
Output for 8.3.11
assign not typed: 1.94 ms assign typed: 2.76 ms
Output for 8.3.10
assign not typed: 1.9 ms assign typed: 2.78 ms
Output for 8.3.9
assign not typed: 1.95 ms assign typed: 3.18 ms
Output for 8.3.8
assign not typed: 1.98 ms assign typed: 2.82 ms
Output for 8.3.7
assign not typed: 1.91 ms assign typed: 2.76 ms
Output for 8.3.6
assign not typed: 1.98 ms assign typed: 2.78 ms
Output for 8.3.5
assign not typed: 1.89 ms assign typed: 2.76 ms
Output for 8.3.3 - 8.3.4
assign not typed: 1.89 ms assign typed: 2.86 ms
Output for 8.3.2
assign not typed: 1.9 ms assign typed: 2.9 ms
Output for 8.3.1
assign not typed: 1.89 ms assign typed: 2.92 ms
Output for 8.3.0
assign not typed: 1.9 ms assign typed: 2.88 ms
Output for 8.2.24
assign not typed: 1.79 ms assign typed: 2.49 ms
Output for 8.2.23
assign not typed: 1.91 ms assign typed: 2.5 ms
Output for 8.2.22
assign not typed: 1.87 ms assign typed: 2.51 ms
Output for 8.2.21
assign not typed: 1.78 ms assign typed: 2.5 ms
Output for 8.2.20
assign not typed: 1.8 ms assign typed: 2.55 ms
Output for 8.2.19
assign not typed: 1.79 ms assign typed: 2.5 ms
Output for 8.2.18
assign not typed: 1.78 ms assign typed: 2.65 ms
Output for 8.2.17
assign not typed: 2.15 ms assign typed: 2.61 ms
Output for 8.2.16
assign not typed: 1.78 ms assign typed: 2.57 ms
Output for 8.2.0, 8.2.15
assign not typed: 1.75 ms assign typed: 2.57 ms
Output for 8.2.14
assign not typed: 1.76 ms assign typed: 2.57 ms
Output for 8.2.13
assign not typed: 1.76 ms assign typed: 2.56 ms
Output for 8.2.12
assign not typed: 1.79 ms assign typed: 2.62 ms
Output for 8.2.11
assign not typed: 1.77 ms assign typed: 2.58 ms
Output for 8.2.10
assign not typed: 3.07 ms assign typed: 3.29 ms
Output for 8.2.7 - 8.2.9
assign not typed: 1.77 ms assign typed: 2.56 ms
Output for 8.2.5 - 8.2.6
assign not typed: 1.77 ms assign typed: 2.57 ms
Output for 8.2.4
assign not typed: 1.8 ms assign typed: 2.57 ms
Output for 8.2.3
assign not typed: 1.83 ms assign typed: 2.56 ms
Output for 8.2.2
assign not typed: 1.8 ms assign typed: 2.58 ms
Output for 8.1.28, 8.1.30, 8.2.1
assign not typed: 1.78 ms assign typed: 2.58 ms
Output for 8.1.29
assign not typed: 1.79 ms assign typed: 2.63 ms
Output for 8.1.27
assign not typed: 1.86 ms assign typed: 2.68 ms
Output for 8.1.26
assign not typed: 1.95 ms assign typed: 2.76 ms
Output for 8.1.23, 8.1.25
assign not typed: 1.8 ms assign typed: 2.66 ms
Output for 8.1.6, 8.1.18, 8.1.24
assign not typed: 1.77 ms assign typed: 2.67 ms
Output for 8.1.22
assign not typed: 2.5 ms assign typed: 2.66 ms
Output for 8.1.21
assign not typed: 1.78 ms assign typed: 2.69 ms
Output for 8.1.20
assign not typed: 1.84 ms assign typed: 2.65 ms
Output for 8.1.19
assign not typed: 1.84 ms assign typed: 2.66 ms
Output for 8.1.3, 8.1.17
assign not typed: 1.76 ms assign typed: 2.67 ms
Output for 8.1.16
assign not typed: 1.84 ms assign typed: 2.68 ms
Output for 8.1.15
assign not typed: 2.45 ms assign typed: 2.82 ms
Output for 8.1.14
assign not typed: 1.79 ms assign typed: 2.69 ms
Output for 8.1.13
assign not typed: 1.78 ms assign typed: 3.42 ms
Output for 8.1.12
assign not typed: 1.78 ms assign typed: 2.66 ms
Output for 8.1.11
assign not typed: 1.76 ms assign typed: 2.69 ms
Output for 8.1.10
assign not typed: 1.79 ms assign typed: 2.66 ms
Output for 8.1.9
assign not typed: 1.78 ms assign typed: 2.68 ms
Output for 8.1.4, 8.1.8
assign not typed: 1.77 ms assign typed: 2.68 ms
Output for 8.1.7
assign not typed: 1.82 ms assign typed: 2.66 ms
Output for 8.1.5
assign not typed: 1.86 ms assign typed: 2.67 ms
Output for 8.1.2
assign not typed: 1.76 ms assign typed: 2.7 ms
Output for 8.1.1
assign not typed: 1.77 ms assign typed: 2.66 ms
Output for 8.1.0
assign not typed: 1.81 ms assign typed: 2.67 ms
Output for 8.0.30
assign not typed: 1.85 ms assign typed: 2.74 ms

preferences:
68.89 ms | 486 KiB | 5 Q