3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static function test() { return true; } } function test() { static $a; return $a ??= new A; } $its = 1e3; $test = test(); $t = hrtime(true); for ( $i=0;$i++<$its;) test()->test(); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $test->test(); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) A::test(); echo (hrtime(true)-$t)/1e9,"s\n"; echo "\n=== Warmed up ===\n\n"; $its = 1e6; $t = hrtime(true); for ( $i=0;$i++<$its;) test()->test(); echo $a=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $test->test(); echo $b=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) A::test(); echo $c=(hrtime(true)-$t)/1e9,"s\n"; echo number_format((($a-$c)/$a) * 100, 2 ), "% faster from function\n"; echo number_format((($b-$c)/$b) * 100, 2 ), "% faster from variable\n";

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.140.0070.05019.08
8.3.130.0100.07618.50
8.3.120.0070.05118.94
8.3.110.0070.04716.50
8.3.100.0100.04524.06
8.3.90.0060.04726.77
8.3.80.0100.05617.97
8.3.70.0170.10116.50
8.3.60.0100.10716.63
8.3.50.0170.10416.41
8.3.40.0030.10520.40
8.3.30.0030.09819.22
8.3.20.0160.07224.18
8.3.10.0100.08024.66
8.3.00.0060.04926.16
8.2.250.0100.04516.75
8.2.240.0130.10717.35
8.2.230.0030.05120.94
8.2.220.0060.05437.54
8.2.210.0030.05326.77
8.2.200.0030.06418.16
8.2.190.0130.11818.39
8.2.180.0100.09216.75
8.2.170.0170.15319.09
8.2.160.0200.09622.96
8.2.150.0000.05425.66
8.2.140.0030.05324.66
8.2.130.0130.07226.16
8.2.120.0100.06920.91
8.2.110.0070.08820.64
8.2.100.0340.05918.44
8.2.90.0270.06718.44
8.2.80.0220.06718.44
8.2.70.0280.06418.44
8.2.60.0230.06418.44
8.2.50.0210.07118.44
8.2.40.0270.06118.44
8.2.30.0260.06218.44
8.2.20.0220.06518.44
8.2.10.0170.07118.44
8.2.00.0130.07318.44
8.1.300.0100.04818.09
8.1.290.0070.06230.84
8.1.280.0160.08925.92
8.1.270.0060.04824.66
8.1.260.0030.05126.35
8.1.250.0030.05028.09
8.1.240.0100.08619.16
8.1.230.0220.06418.44
8.1.220.0180.06818.44
8.1.210.0240.06418.44
8.1.200.0140.07218.44
8.1.190.0250.06118.44
8.1.180.0210.06618.44
8.1.170.0300.06018.44
8.1.160.0270.06118.44
8.1.150.0200.06618.44
8.1.140.0230.06518.44
8.1.130.0310.06018.44
8.1.120.0140.07318.44
8.1.110.0210.06718.44
8.1.100.0290.06018.44
8.1.90.0160.06918.44
8.1.80.0250.06318.44
8.1.70.0210.06918.44
8.1.60.0240.06618.44
8.1.50.0260.06118.44
8.1.40.0230.06818.44
8.1.30.0220.07118.44
8.1.20.0170.07118.44
8.1.10.0240.06518.44
8.1.00.0130.07118.44
8.0.300.0150.08118.44
8.0.290.0220.06718.44
8.0.280.0210.06918.44
8.0.270.0110.07718.44
8.0.260.0200.07518.44
8.0.250.0150.07218.44
8.0.240.0200.06818.44
8.0.230.0270.06218.44
8.0.220.0250.06518.44
8.0.210.0240.06518.44
8.0.200.0230.06618.44
8.0.190.0200.06918.44
8.0.180.0260.06218.44
8.0.170.0290.05918.44
8.0.160.0210.06918.44
8.0.150.0210.06918.44
8.0.140.0290.06418.44
8.0.130.0250.06118.44
8.0.120.0310.05918.44
8.0.110.0250.06118.44
8.0.100.0270.06118.44
8.0.90.0310.05518.44
8.0.80.0210.06618.44
8.0.70.0200.06718.44
8.0.60.0240.06718.44
8.0.50.0270.06218.44
8.0.30.0210.06618.44
8.0.20.0270.06418.44
8.0.10.0210.06618.44

preferences:
48.38 ms | 403 KiB | 5 Q