3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { protected $val = []; function notempty() { return ! empty( $this->val ); } function booltest() { return (bool) $this->val; } } $its = 1e3; $x = new X; $t = hrtime(true); for ($i=0;$i++<$its;) $x->notempty(); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ($i=0;$i++<$its;) $x->booltest(); echo (hrtime(true)-$t)/1e9,"s\n"; echo "\n=== Warmed up ===\n\n"; $its = 1e5; $t = hrtime(true); for ($i=0;$i++<$its;) $x->notempty(); echo 'notempty: ', $a=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ($i=0;$i++<$its;) $x->booltest(); echo 'bool : ', $b=(hrtime(true)-$t)/1e9,"s\n"; echo 'bool is ', number_format((($a-$b)/$a) * 100, 2 ), "% faster than notempty chain\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.5.10.0090.02116.49
8.5.00.0160.02119.96
8.4.160.0110.01923.94
8.4.150.0030.00014.05
8.4.140.0100.02020.42
8.4.130.0140.01317.63
8.4.120.0100.01322.52
8.4.110.0140.00922.70
8.4.100.0130.01518.75
8.4.90.0120.01618.55
8.4.80.0090.01518.63
8.4.70.0030.00917.99
8.4.60.0050.00718.66
8.4.50.0020.01018.53
8.4.40.0030.01017.74
8.4.30.0060.01618.59
8.4.20.0100.02018.07
8.4.10.0060.00619.57
8.3.290.0140.01820.68
8.3.280.0110.01918.56
8.3.270.0160.01416.71
8.3.260.0120.01416.60
8.3.250.0130.01318.78
8.3.240.0050.00717.21
8.3.230.0140.01316.62
8.3.220.0020.01018.92
8.3.210.0160.01218.36
8.3.200.0050.00716.45
8.3.190.0090.01918.90
8.3.180.0090.01816.56
8.3.170.0060.02020.54
8.3.160.0120.01518.99
8.3.150.0160.00917.29
8.3.140.0070.02016.57
8.3.130.0040.00816.55
8.3.120.0030.01020.74
8.3.110.0060.00616.62
8.3.100.0060.00616.78
8.3.90.0000.01126.77
8.3.80.0070.00718.43
8.3.70.0110.01118.31
8.3.60.0170.01418.50
8.3.50.0100.01016.57
8.3.40.0140.00723.64
8.3.30.0130.00721.96
8.3.20.0140.01425.66
8.3.10.0070.01825.66
8.3.00.0000.02225.66
8.2.300.0150.01518.85
8.2.290.0090.01520.61
8.2.280.0110.01618.32
8.2.270.0100.01717.18
8.2.260.0000.02218.46
8.2.250.0060.00618.50
8.2.240.0060.00616.55
8.2.230.0080.00320.94
8.2.220.0080.00424.06
8.2.210.0140.01126.77
8.2.200.0030.01018.54
8.2.190.0070.01416.66
8.2.180.0160.01618.41
8.2.170.0070.01418.80
8.2.160.0130.01322.96
8.2.150.0040.01825.66
8.2.140.0060.01525.66
8.2.130.0070.01425.66
8.2.120.0100.00725.66
8.2.110.0060.00625.66
8.2.100.0030.00825.66
8.2.90.0040.00825.66
8.2.80.0040.00725.66
8.2.70.0030.01025.66
8.2.60.0040.00825.66
8.2.50.0060.00625.66
8.2.40.0000.01225.66
8.2.30.0060.00625.66
8.2.20.0000.01225.66
8.2.10.0060.00625.66
8.2.00.0030.00925.66
8.1.340.0060.01119.89
8.1.330.0030.00822.05
8.1.320.0120.01516.34
8.1.310.0040.02216.58
8.1.300.0060.00618.68
8.1.290.0030.01030.84
8.1.280.0120.00925.92
8.1.270.0060.00625.66
8.1.260.0080.00425.66
8.1.250.0060.00625.66
8.1.240.0000.01225.66
8.1.230.0040.00825.66
8.1.220.0060.00625.66
8.1.210.0080.00425.66
8.1.200.0060.00625.66
8.1.190.0080.00425.66
8.1.180.0040.01125.66
8.1.170.0100.00325.66
8.1.160.0060.00625.66
8.1.150.0060.00625.66
8.1.140.0040.00825.66
8.1.130.0040.00725.66
8.1.120.0070.00725.66
8.1.110.0030.01025.66
8.1.100.0000.01225.66
8.1.90.0060.00625.66
8.1.80.0060.00625.66
8.1.70.0040.00825.66
8.1.60.0070.01025.66
8.1.50.0030.01025.66
8.1.40.0040.00825.66
8.1.30.0090.00325.66
8.1.20.0040.00825.66
8.1.10.0040.00825.66
8.1.00.0080.00425.66

preferences:
34.55 ms | 403 KiB | 5 Q