3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface I {} class A implements I{} $results = []; [$key, $value] = compute('instanceof [object]', function($instance) { $instance instanceof I; }); $results[$key] = $value; [$key, $value] = compute('class_implements [object]', function($instance) { in_array(I::class, class_implements(A::class)); }); $results[$key] = $value; [$key, $value] = compute('is_a [object]', function($instance) { is_a($instance, I::class); }); $results[$key] = $value; [$key, $value] = compute('is_a [class]', function($instance) { is_a(A::class, I::class, true); }); $results[$key] = $value; [$key, $value] = compute('reflection [class]', function($instance) { ( new ReflectionClass(A::class))->implementsInterface(I::class); }); $results[$key] = $value; function compute($name, $callback) { $instance = new A; $start = microtime(true); for($i = 1e5; $i; $i--) { $callback($instance); } $elapsedMs = (microtime(true) - $start)*1000; return [$name, $elapsedMs]; } asort($results); $best = min($results); $results = array_map(function($result) use($best) { return [ $result, $result / $best, ]; }, $results); $performance = 0; foreach($results as $name => $result) { [$elapsedMs, $performance] = $result; $extraTimeInPercent = ($performance - 1) * 100; echo sprintf( '%25s took %6.2f ms | +%3.0f%% | %s', $name, $elapsedMs, $extraTimeInPercent, str_pad('', ($performance * 10), '.') ) . PHP_EOL; }

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.2.60.0190.08317.25
8.2.30.0050.07217.75
8.1.170.0110.07417.62
8.1.100.0050.07317.46
8.1.90.0160.06817.35
8.1.80.0060.07817.43
8.1.70.0160.07417.54
8.1.60.0120.07617.57
8.1.50.0130.07517.56
8.1.40.0130.07517.50
8.1.30.0110.07417.71
8.1.20.0100.07617.71
8.1.10.0120.07617.58
8.1.00.0100.08117.53
8.0.220.0130.07016.99
8.0.210.0100.07216.94
8.0.200.0060.07817.04
8.0.190.0110.07416.94
8.0.180.0070.07716.95
8.0.170.0020.08316.93
8.0.160.0020.08416.97
8.0.150.0080.07616.77
8.0.140.0090.07516.95
8.0.130.0100.07516.91
8.0.120.0090.07916.88
8.0.110.0070.08316.90
8.0.100.0090.07916.94
8.0.90.0080.08116.95
8.0.80.0100.08516.94
8.0.70.0090.07916.84
8.0.60.0120.07716.90
8.0.50.0110.07116.89
8.0.30.0070.07716.90
8.0.20.0100.07416.93
8.0.10.0080.07417.01
8.0.00.0040.07917.10
7.4.300.0130.07516.51
7.4.290.0150.07316.60
7.4.280.0070.07716.55
7.4.270.0130.07816.57
7.4.260.0130.08316.58
7.4.250.0130.08016.64
7.4.240.0110.07616.60
7.4.230.0120.07716.64
7.4.220.0090.07616.59
7.4.210.0120.07716.55
7.4.200.0100.07516.60
7.4.190.0110.08316.67
7.4.180.0070.07716.57
7.4.160.0110.07516.61
7.4.150.0120.07416.59
7.4.140.0110.07316.48
7.4.130.0110.07516.52
7.4.120.0070.08716.49
7.4.110.0110.07816.57
7.4.100.0080.07616.50
7.4.90.0090.08216.53
7.4.80.0130.08016.46
7.4.70.0120.07916.47
7.4.60.0100.08116.52
7.4.50.0090.08016.38
7.4.40.0080.08016.37
7.4.30.0110.09216.45
7.4.20.0120.09316.53
7.4.10.0100.08516.45
7.4.00.0100.08316.47
7.3.330.0120.08016.23
7.3.320.0110.07516.41
7.3.310.0040.07816.31
7.3.300.0100.07816.37
7.3.290.0090.08016.32
7.3.280.0070.08716.35
7.3.270.0100.07916.35
7.3.260.0110.08016.43
7.3.250.0110.07916.39
7.3.240.0100.08416.37
7.3.230.0120.08516.29
7.3.220.0100.08316.27
7.3.210.0050.09016.38
7.3.200.0090.09516.32
7.3.190.0080.08916.33
7.3.180.0050.09416.33
7.3.170.0070.08916.39
7.3.160.0060.09516.28
7.3.150.0090.09016.34
7.3.140.0100.08816.31
7.3.130.0100.09616.36
7.3.120.0100.08916.38
7.3.110.0110.10016.37
7.3.100.0110.08916.32
7.3.90.0110.08516.55
7.3.80.0110.08816.40
7.3.70.0100.08916.38
7.3.60.0130.08916.46
7.3.50.0090.09316.45
7.3.40.0090.09516.44
7.3.30.0100.08816.39
7.3.20.0100.09117.36
7.3.10.0130.08617.32
7.3.00.0100.09317.28
7.2.340.0110.08516.51
7.2.330.0090.09816.46
7.2.320.0110.09216.49
7.2.310.0070.11516.40
7.2.300.0120.09316.42
7.2.290.0120.09516.77
7.2.280.0090.09716.44
7.2.270.0120.09516.53
7.2.260.0100.09916.51
7.2.250.0120.09716.55
7.2.240.0090.09716.53
7.2.230.0120.09116.51
7.2.220.0100.09816.50
7.2.210.0090.09516.48
7.2.200.0100.09216.68
7.2.190.0140.09416.56
7.2.180.0080.11516.54
7.2.170.0120.10816.56
7.2.160.0120.10316.66
7.2.150.0100.10317.49
7.2.140.0100.09617.61
7.2.130.0120.09917.59
7.2.120.0110.10117.59
7.2.110.0100.09417.64
7.2.100.0110.10817.58
7.2.90.0130.11617.53
7.2.80.0160.09817.53
7.2.70.0110.09917.55
7.2.60.0130.11417.50
7.2.50.0110.09817.52
7.2.40.0110.11017.62
7.2.30.0140.09617.59
7.2.20.0140.09517.54
7.2.10.0110.10417.55
7.2.00.0100.09717.58

preferences:
26.65 ms | 403 KiB | 5 Q