3v4l.org

run code in 300+ PHP versions simultaneously
<?php function benchmark($n) { $iterations = intval(1000000 / $n); print "$iterations iterations, $n range\n"; $a = range(0, $n); $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) (array) $a !== $a; $trick = microtime(TRUE) - $start; $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) !is_array($a); $is_array = microtime(TRUE) - $start; print '(array) !== is ' . ($trick < $is_array ? 'faster' : 'slower') ." than !is_array() for arrays and $n\n"; $a = range(0, $n); $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) (array) $a === $a; $trick = microtime(TRUE) - $start; $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) is_array($a); $is_array = microtime(TRUE) - $start; print '(array) === is ' . ($trick < $is_array ? 'faster' : 'slower') ." than is_array() for arrays and $n\n"; $a = (object) range(0, $n); $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) (array) $a !== $a; $trick = microtime(TRUE) - $start; $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) !is_array($a); $is_array = microtime(TRUE) - $start; print '(array) !== is ' . ($trick < $is_array ? 'faster' : 'slower') ." than !is_array() for object and $n\n"; $a = (object) range(0, $n); $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) (array) $a === $a; $trick = microtime(TRUE) - $start; $start = microtime(TRUE); for ($i = 1; $i < $iterations; $i++) is_array($a); $is_array = microtime(TRUE) - $start; print '(array) === is ' . ($trick < $is_array ? 'faster' : 'slower') ." than is_array() for objects and $n\n"; } benchmark(10); print "\n"; benchmark(140); print "\n"; benchmark(150); print "\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)
7.4.10.0130.18214.80
7.4.00.0030.18615.20
7.3.130.0130.18014.94
7.3.120.0070.18414.91
7.3.110.0100.12114.71
7.3.100.0000.13514.83
7.3.90.0000.18414.96
7.3.80.0100.13814.82
7.3.70.0030.13015.00
7.3.60.0100.18015.00
7.3.50.0070.17515.04
7.3.40.0020.13014.91
7.3.30.0070.13114.71
7.3.20.0130.11916.45
7.3.10.0030.14316.64
7.3.00.0030.15916.47
7.2.260.0030.19614.98
7.2.250.0100.19915.24
7.2.240.0030.17414.96
7.2.230.0130.14515.14
7.2.220.0100.16915.09
7.2.210.0070.15815.02
7.2.200.0030.14414.77
7.2.190.0000.14315.26
7.2.180.0000.13015.00
7.2.170.0030.12115.07
7.2.160.0070.14115.32
7.2.150.0030.12516.82
7.2.140.0070.17217.00
7.2.130.0030.13917.03
7.2.120.0030.12116.80
7.2.110.0100.12916.98
7.2.100.0000.21316.80
7.2.90.0000.21517.03
7.2.80.0030.15516.94
7.2.70.0070.13717.02
7.2.60.0100.11116.99
7.2.50.0030.18117.09
7.2.40.0100.12416.86
7.2.30.0030.11816.79
7.2.20.0030.21017.08
7.2.10.0030.16116.96
7.2.00.0030.15416.93
7.1.330.0000.06815.78
7.1.320.0130.05815.87
7.1.310.0130.06015.68
7.1.300.0070.06515.74
7.1.290.0000.07315.91
7.1.280.0070.05615.70
7.1.270.0030.06115.96
7.1.260.0070.07315.89
7.1.250.0060.05215.99
7.1.240.0030.06015.65
7.1.230.0070.05615.96
7.1.220.0030.05415.84
7.1.210.0070.06715.66
7.1.200.0000.06315.81
7.1.190.0070.06015.98
7.1.180.0060.06215.85
7.1.170.0030.05715.79
7.1.160.0030.07615.60
7.1.150.0000.06815.58
7.1.140.0000.07615.91
7.1.130.0070.07315.98
7.1.120.0030.07215.99
7.1.110.0000.06115.67
7.1.100.0070.05715.93
7.1.90.0000.06515.54
7.1.80.0070.04915.96
7.1.70.0070.04216.55
7.1.60.0030.06617.66
7.1.50.0070.03916.49
7.1.40.0030.07415.64
7.1.30.0000.07415.89
7.1.20.0030.07015.97
7.1.10.0000.07915.68
7.1.00.0030.08419.25
7.0.330.0030.06215.45
7.0.320.0070.07715.42
7.0.310.0030.07315.22
7.0.300.0030.07615.37
7.0.290.0030.06515.23
7.0.280.0030.06315.35
7.0.270.0030.07815.57
7.0.260.0030.06415.14
7.0.250.0030.06515.45
7.0.240.0070.07215.17
7.0.230.0030.05815.54
7.0.220.0060.06115.63
7.0.210.0030.06215.64
7.0.200.0220.04315.17
7.0.190.0070.07215.40
7.0.180.0030.07215.51
7.0.170.0100.05515.53
7.0.160.0000.06415.48
7.0.150.0030.05615.44
7.0.140.0050.08618.73
7.0.130.0030.06015.45
7.0.120.0020.08418.79
7.0.110.0030.07215.46
7.0.100.0000.07715.24
7.0.90.0030.05915.50
7.0.80.0220.06917.63
7.0.70.0070.09117.71
7.0.60.0300.07217.71
7.0.50.0050.06217.85
7.0.40.0100.06716.82
7.0.30.0030.06616.75
7.0.20.0030.06316.72
7.0.10.0050.06116.89
7.0.00.0070.06516.72
5.6.400.0100.68614.09
5.6.390.0030.63114.69
5.6.380.0030.72914.39
5.6.370.0030.67514.68
5.6.360.0070.68414.64
5.6.350.0030.69314.18
5.6.340.0030.67914.31
5.6.330.0030.66914.05
5.6.320.0100.65414.39
5.6.310.0030.68214.41
5.6.300.0100.77014.43
5.6.290.0070.64814.33
5.6.280.0030.73317.76
5.6.270.0070.90914.30
5.6.260.0070.90214.38
5.6.250.0070.81814.18
5.6.240.0030.81914.22
5.6.230.0080.63417.55
5.6.220.0100.63717.61
5.6.210.0070.65817.32
5.6.200.0030.63517.64
5.6.190.0050.65717.85
5.6.180.0120.65517.66
5.6.170.0100.55717.77
5.6.160.0020.57317.66
5.6.150.0070.62617.72
5.6.140.0070.57517.92
5.6.130.0070.66717.82
5.6.120.0020.60017.71
5.6.110.0030.60617.74
5.6.100.0070.57717.78
5.6.90.0070.68717.94
5.6.80.0050.54217.35
5.6.70.0030.67217.30
5.6.60.0080.62317.38
5.6.50.0070.58517.44
5.6.40.0100.69017.27
5.6.30.0070.58317.33
5.6.20.0080.62917.50
5.6.10.0070.72017.43
5.6.00.0070.61317.39
5.5.380.0030.73514.59
5.5.370.0150.56817.53
5.5.360.0030.67917.27
5.5.350.0120.69317.33
5.5.340.0080.56717.57
5.5.330.0030.63217.71
5.5.320.0050.66517.59
5.5.310.0100.58917.51
5.5.300.0050.61017.71
5.5.290.0050.68417.75
5.5.280.0080.69617.73
5.5.270.0050.66617.68
5.5.260.0070.69217.50
5.5.250.0080.69817.60
5.5.240.0070.68917.33
5.5.230.0070.72417.14
5.5.220.0030.65117.31
5.5.210.0070.72417.34
5.5.200.0030.66617.14
5.5.190.0070.64217.40
5.5.180.0080.59417.41
5.5.170.0100.64714.31
5.5.160.0050.63717.17
5.5.150.0070.71717.33
5.5.140.0030.68917.20
5.5.130.0050.57817.40
5.5.120.0080.52917.04
5.5.110.0020.62417.24
5.5.100.0050.67217.13
5.5.90.0050.64717.12
5.5.80.0070.58017.29
5.5.70.0020.64117.15
5.5.60.0020.55117.28
5.5.50.0050.66617.34
5.5.40.0030.58517.27
5.5.30.0070.65317.24
5.5.20.0100.58017.13
5.5.10.0020.53217.28
5.5.00.0070.62717.17
5.4.450.0030.53319.54
5.4.440.0130.47719.27
5.4.430.0000.46719.35
5.4.420.0100.51719.45
5.4.410.0070.52019.24
5.4.400.0030.49019.14
5.4.390.0100.50719.04
5.4.380.0200.56719.23
5.4.370.0030.51319.12
5.4.360.0130.47718.85
5.4.350.0100.49319.05
5.4.340.0030.50019.03
5.4.320.0070.49319.05
5.4.310.0070.43718.85
5.4.300.0000.51319.12
5.4.290.0030.65019.02
5.4.280.0070.38019.16
5.4.270.0100.39719.09
5.4.260.0070.39719.04
5.4.250.0030.47019.02
5.4.240.0100.47319.21
5.4.230.0100.53019.04
5.4.220.0030.60019.07
5.4.210.0130.51719.04
5.4.200.0030.47718.82
5.4.190.0070.48719.02
5.4.180.0000.53719.22
5.4.170.0030.42318.83
5.4.160.0030.52719.09
5.4.150.0000.51719.11
5.4.140.0130.48016.43
5.4.130.0030.50316.50
5.4.120.0070.51716.41
5.4.110.0100.51016.48
5.4.100.0070.52316.48
5.4.90.0030.52016.50
5.4.80.0000.54316.38
5.4.70.0070.43016.46
5.4.60.0100.40716.57
5.4.50.0000.47016.50
5.4.40.0230.41016.36
5.4.30.0000.43716.52
5.4.20.0030.51016.43
5.4.10.0030.43316.36
5.4.00.0030.41715.86
5.3.290.0100.53014.77
5.3.280.0270.40314.61
5.3.270.0070.51314.79
5.3.260.0070.51314.68
5.3.250.0030.45714.61
5.3.240.0100.51314.67
5.3.230.0100.49714.70
5.3.220.0030.51014.61
5.3.210.0130.50714.72
5.3.200.0100.48314.63
5.3.190.0030.50714.76
5.3.180.0030.50714.56
5.3.170.0030.50014.60
5.3.160.0170.51014.72
5.3.150.0070.53714.68
5.3.140.0100.39714.70
5.3.130.0070.46714.68
5.3.120.0070.51714.55
5.3.110.0030.50314.61
5.3.100.0070.46314.14
5.3.90.0100.41714.12
5.3.80.0030.47314.11
5.3.70.0000.41014.02
5.3.60.0000.58714.19
5.3.50.0030.45013.95
5.3.40.0100.54313.95
5.3.30.0030.43714.12
5.3.20.0170.51313.68
5.3.10.0030.43313.64
5.3.00.0030.46713.63
5.2.170.0030.40313.49
5.2.160.0000.53013.49
5.2.150.0030.51013.49
5.2.140.0030.46013.49
5.2.130.0030.51313.49
5.2.120.0030.51013.49
5.2.110.0030.52013.49
5.2.100.0100.46313.49
5.2.90.0100.50713.49
5.2.80.0070.53013.49
5.2.70.0030.50313.49
5.2.60.0000.46713.49
5.2.50.0130.54713.49
5.2.40.0070.54313.49
5.2.30.0000.52013.49
5.2.20.0030.53713.49
5.2.10.0030.58313.49
5.2.00.0070.53713.49
5.1.60.0030.56713.49
5.1.50.0030.53313.49
5.1.40.0030.47013.49
5.1.30.0030.61713.49
5.1.20.0030.58313.49
5.1.10.0070.54313.49
5.1.00.0070.53013.49
5.0.50.0000.74713.49
5.0.40.0000.74013.49
5.0.30.0000.72013.49
5.0.20.0070.73013.49
5.0.10.0030.68313.49
5.0.00.0030.57713.49
4.4.90.0030.69713.49
4.4.80.0030.73713.49
4.4.70.0030.73313.49
4.4.60.0000.66313.49
4.4.50.0030.74013.49
4.4.40.0100.71713.49
4.4.30.0000.71313.49
4.4.20.0030.70313.49
4.4.10.0000.74013.49
4.4.00.0000.72313.49
4.3.110.0000.72013.49
4.3.100.0070.75013.49
4.3.90.0030.75713.49
4.3.80.0070.61013.49
4.3.70.0000.57313.49
4.3.60.0030.71013.49
4.3.50.0000.74713.49
4.3.40.0000.63013.49
4.3.30.0030.73013.49
4.3.20.0070.71013.49
4.3.10.0000.67713.49
4.3.00.0030.72313.49

preferences:
38.7 ms | 401 KiB | 5 Q