3v4l.org

run code in 300+ PHP versions simultaneously
<?php function timeClosures( $n ) { $start = microtime( true ); for ( $i = 0; $i < $n; $i++ ) { $closure = function( $x ) use ( $i ) { return $i*$x; }; } $sec = microtime( true ) - $start; print " It took $sec seconds to create $n closures.\n"; return $sec; } class ClosureBenchmarkTestClass { private $x; public function __construct( $x ) { $this->x = $x; } public function foo( $y ) { return $this->x * $y; } } function timeObjects( $n ) { $start = microtime( true ); for ( $i = 0; $i < $n; $i++ ) { $obj = new ClosureBenchmarkTestClass( $i ); } $sec = microtime( true ) - $start; print " It took $sec seconds to create $n objects.\n"; return $sec; } $m = 10; $n = 1000000; for ( $i = 0; $i < $m; $i++ ) { $ctime = timeClosures( $n ); $otime = timeObjects( $n ); $dtime = $ctime - $otime; $rtime = ( $ctime / $otime ); $fasterOrSlower = $dtime > 0 ? 'faster' : 'slower'; print sprintf( "Creating %d objects was %f seconds %s (%d%%).\n", $n, abs( $dtime ), $fasterOrSlower, abs( $rtime ) * 100 ); }

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.0072.49215.05
7.4.00.0072.49214.68
7.3.130.0072.49214.86
7.3.120.0072.49215.08
7.3.110.0072.39714.84
7.3.100.0082.47815.00
7.3.90.0032.49614.66
7.3.80.0032.49314.44
7.3.70.0032.36314.98
7.3.60.0072.49214.89
7.3.50.0032.49514.89
7.3.40.0032.33514.92
7.3.30.0072.49214.81
7.3.20.0002.49816.66
7.3.10.0102.48816.55
7.3.00.0032.49316.74
7.2.260.0102.48214.98
7.2.250.0032.49415.28
7.2.240.0072.49214.95
7.2.230.0132.48615.21
7.2.220.0132.48514.82
7.2.210.0072.49215.14
7.2.200.0072.49214.78
7.2.190.0102.48315.02
7.2.180.0072.49215.11
7.2.170.0032.49614.99
7.2.160.0072.49114.92
7.2.150.0132.48616.66
7.2.140.0132.47917.00
7.2.130.0072.49216.83
7.2.120.0002.49916.89
7.2.110.0072.49016.91
7.2.100.0102.48916.97
7.2.90.0072.49016.70
7.2.80.0072.48616.91
7.2.70.0032.49416.65
7.2.60.0032.49517.04
7.2.50.0032.49016.69
7.2.40.0002.49816.86
7.2.30.0062.48817.10
7.2.20.0002.49916.99
7.2.10.0072.49216.69
7.2.00.0002.49716.78
7.1.330.0062.48615.82
7.1.320.0032.49416.04
7.1.310.0002.49715.80
7.1.300.0162.47315.79
7.1.290.0002.49215.78
7.1.280.0002.49915.64
7.1.270.0032.49215.59
7.1.260.0032.48815.63
7.1.250.0072.49116.02
7.1.240.0072.49215.89
7.1.230.0032.49515.94
7.1.220.0032.49315.81
7.1.210.0072.49215.64
7.1.200.0032.49515.78
7.1.190.0002.49615.89
7.1.180.0032.49615.56
7.1.170.0032.49515.69
7.1.160.0002.49315.77
7.1.150.0002.49715.52
7.1.140.0002.49815.88
7.1.130.0002.49815.95
7.1.120.0032.49615.54
7.1.110.0072.48515.91
7.1.100.0032.49515.90
7.1.90.0002.49415.68
7.1.80.0032.49615.73
7.1.70.0032.42016.66
7.1.60.0022.30617.73
7.1.50.0032.37516.49
7.1.40.0032.49515.73
7.1.30.0002.49615.73
7.1.20.0002.49915.65
7.1.10.0032.48515.87
7.1.00.0062.31819.16
7.0.330.0032.49515.61
7.0.320.0032.49515.51
7.0.310.0032.49515.38
7.0.300.0032.49615.43
7.0.290.0032.49615.65
7.0.280.0032.49615.17
7.0.270.0072.49215.64
7.0.260.0032.49315.39
7.0.250.0032.49415.61
7.0.240.0072.49215.64
7.0.230.0102.48815.48
7.0.220.0132.48415.30
7.0.210.0032.49615.40
7.0.200.0042.49216.03
7.0.190.0072.49015.57
7.0.180.0032.49515.48
7.0.170.0102.48915.34
7.0.160.0102.48715.62
7.0.150.0102.42515.68
7.0.140.0032.49218.63
7.0.130.0032.49415.51
7.0.120.0032.49515.39
7.0.110.0102.48315.52
7.0.100.0152.38117.72
7.0.90.0152.42317.76
7.0.80.0102.48117.61
7.0.70.0022.29917.58
7.0.60.0052.36317.67
7.0.50.0072.39717.77
7.0.40.0032.41616.82
7.0.30.0082.41616.88
7.0.20.0022.39016.76
7.0.10.0022.39016.85
7.0.00.0032.49616.89
5.6.400.0072.49214.50
5.6.390.0002.49214.34
5.6.380.0102.48814.09
5.6.370.0032.49414.53
5.6.360.0032.49514.77
5.6.350.0072.49114.36
5.6.340.0032.49414.43
5.6.330.0032.49514.56
5.6.320.0002.49914.46
5.6.310.0032.49514.31
5.6.300.0002.49514.42
5.6.290.0032.49614.73
5.6.280.0082.49017.74
5.6.270.0032.49614.75
5.6.260.0002.49914.55
5.6.250.0002.49917.53
5.6.240.0032.49417.51
5.6.230.0072.49317.45
5.6.220.0052.49417.74
5.6.210.0082.49017.46
5.6.200.0102.47617.93
5.6.190.0072.49317.68
5.6.180.0102.48917.64
5.6.170.0052.48317.68
5.6.160.0032.46417.52
5.6.150.0022.49717.79
5.6.140.0082.47417.83
5.6.130.0072.49317.71
5.6.120.0082.46817.81
5.6.110.0022.46817.73
5.6.100.0032.49117.72
5.6.90.0052.42117.72
5.6.80.0052.46317.50
5.6.70.0072.47317.48
5.6.60.0022.49117.44
5.6.50.0082.47917.47
5.6.40.0052.48017.39
5.6.30.0072.48817.54
5.6.20.0072.47417.49
5.6.10.0052.48617.45
5.6.00.0072.34417.39
5.5.380.0082.40217.34
5.5.370.0032.49317.48
5.5.360.0082.49117.38
5.5.350.0032.49617.50
5.5.340.0072.48717.63
5.5.330.0032.49217.56
5.5.320.0102.47917.73
5.5.310.0072.47917.51
5.5.300.0022.48817.69
5.5.290.0072.40917.63
5.5.280.0102.48917.48
5.5.270.0052.48817.69
5.5.260.0032.48317.53
5.5.250.0122.47817.47
5.5.240.0072.47617.19
5.5.230.0112.47817.15
5.5.220.0132.45917.40
5.5.210.0082.47917.42
5.5.200.0072.47917.20
5.5.190.0052.47517.45
5.5.180.0052.48917.41
5.5.170.0102.48914.51
5.5.160.0052.46917.17
5.5.150.0032.48817.23
5.5.140.0022.48517.36
5.5.130.0072.47217.36
5.5.120.0032.48417.22
5.5.110.0102.49017.20
5.5.100.0052.46917.21
5.5.90.0102.46117.14
5.5.80.0072.47217.26
5.5.70.0102.47117.20
5.5.60.0122.47917.08
5.5.50.0132.47717.03
5.5.40.0072.48617.10
5.5.30.0052.46017.21
5.5.20.0052.48417.28
5.5.10.0072.47917.34
5.5.00.0032.48817.13
5.4.450.0072.47316.41
5.4.440.0082.49116.50
5.4.430.0082.49116.42
5.4.420.0052.49416.34
5.4.410.0052.49116.34
5.4.400.0032.49616.23
5.4.390.0022.49716.19
5.4.380.0052.49416.26
5.4.370.0052.49416.34
5.4.360.0022.49716.23
5.4.350.0072.49316.29
5.4.340.0082.48816.25
5.4.330.0072.49213.52
5.4.320.0052.49416.26
5.4.310.0022.49716.25
5.4.300.0052.49316.33
5.4.290.0072.49316.33
5.4.280.0102.48416.28
5.4.270.0122.48716.18
5.4.260.0052.49416.25
5.4.250.0022.49816.17
5.4.240.0052.49416.24
5.4.230.0082.49016.17
5.4.220.0052.49416.20
5.4.210.0062.49316.24
5.4.200.0072.49216.32
5.4.190.0052.49116.22
5.4.180.0952.40316.28
5.4.170.0022.49716.25
5.4.160.0082.49116.17
5.4.150.0032.49616.27
5.4.140.0072.45914.86
5.4.130.0032.49514.90
5.4.120.0032.49414.96
5.4.110.0052.49214.89
5.4.100.0072.49314.92
5.4.90.0032.49515.00
5.4.80.0102.48914.90
5.4.70.0022.49614.97
5.4.60.0032.49314.88
5.4.50.0072.49214.92
5.4.40.0032.49514.97
5.4.30.1152.38414.99
5.4.20.0072.49314.87
5.4.10.0082.49114.95
5.4.00.0052.49214.57
5.3.290.0032.49714.48
5.3.280.0072.49314.42
5.3.270.0032.49714.48
5.3.260.0072.49314.59
5.3.250.0102.49014.50
5.3.240.0132.48714.39
5.3.230.0032.49714.38
5.3.220.0102.49014.39
5.3.210.0072.49314.48
5.3.200.0002.50014.39
5.3.190.0032.49714.56
5.3.180.0002.50014.47
5.3.170.0102.49014.39
5.3.160.0102.49014.50
5.3.150.0102.49014.48
5.3.140.0072.49314.34
5.3.130.0102.49014.33
5.3.120.0072.49314.46
5.3.110.3502.14714.43
5.3.100.0132.48713.80
5.3.90.0032.49713.79
5.3.80.0102.49013.78
5.3.70.0002.50013.82
5.3.60.0132.48713.76
5.3.50.0032.49713.66
5.3.40.0072.49313.82
5.3.30.0072.49313.72
5.3.20.0072.49313.48
5.3.10.0002.50013.55
5.3.00.0102.49013.35
5.2.170.0000.02711.00
5.2.160.0030.02711.20
5.2.150.0030.06311.18
5.2.140.0030.05311.21
5.2.130.0030.04311.02
5.2.120.0030.02711.12
5.2.110.0030.02311.21
5.2.100.0100.05311.09
5.2.90.0100.04311.11
5.2.80.0030.04711.08
5.2.70.0030.05311.16
5.2.60.0070.06011.05
5.2.50.0000.06711.09
5.2.40.0030.06310.85
5.2.30.0030.05011.11
5.2.20.0100.04711.05
5.2.10.0030.06010.82
5.2.00.0030.04710.73
5.1.60.0030.05310.07
5.1.50.0030.0539.98
5.1.40.0030.0239.81
5.1.30.0070.04310.36
5.1.20.0070.04010.39
5.1.10.0000.04310.15
5.1.00.0000.06010.16
5.0.50.0030.0438.60
5.0.40.0070.0408.40
5.0.30.0070.0578.21
5.0.20.0030.0438.04
5.0.10.0030.0438.01
5.0.00.0000.0338.25
4.4.90.0000.0377.85
4.4.80.0000.0407.85
4.4.70.0030.0277.85
4.4.60.0030.0377.85
4.4.50.0000.0377.85
4.4.40.0000.0437.85
4.4.30.0070.0277.85
4.4.20.0030.0377.85
4.4.10.0000.0377.85
4.4.00.0000.0537.85
4.3.110.0030.0277.85
4.3.100.0000.0207.85
4.3.90.0000.0337.85
4.3.80.0000.0607.85
4.3.70.0030.0177.85
4.3.60.0030.0207.85
4.3.50.0000.0337.85
4.3.40.0100.0277.85
4.3.30.0030.0337.85
4.3.20.0030.0307.85
4.3.10.0030.0277.85
4.3.00.0000.0337.85

preferences:
38.62 ms | 401 KiB | 5 Q