3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Dont' abuse 3v4l $n = 10000; // 空循环时间 $start = microtime(true); for ($i = 0; $i < $n; $i++) { } $finish = microtime(true); $loop_time = $finish - $start; // 普通 $start = microtime(true); for ($i = 0; $i < $n; $i++) { $t = time(); } $finish = microtime(true); $microtime_time = $finish - $start - $loop_time; echo "microtime: $microtime_time \t100%" . PHP_EOL; // 方式一:通过 PHP 实现,时间缓存在静态变量中 class CacheTime { private static $time = 0; public static function getTime() { return self::$time; } // 需要 timer 定时调用 setTime 更新 public static function setTime() { self::$time = microtime(true); } } $start = microtime(true); for ($i = 0; $i < $n; $i++) { $t = CacheTime::getTime(); } $finish = microtime(true); $class_cache_time = $finish - $start - $loop_time; echo "CacheTime: $class_cache_time \t" . ($class_cache_time / $microtime_time * 100) . '%' . PHP_EOL;; // 方式二:通过扩展实现,时间存在 C 的静态/全局变量中,通过定时器更新 $start = microtime(true); for ($i = 0; $i < $n; $i++) { // gc_enabled 直接取 GC_G(gc_enabled),没有参数,接近时间缓存的实现 $t = gc_enabled(); } $finish = microtime(true); $c_cache_time = $finish - $start - $loop_time; echo "cache_time: $c_cache_time \t" . ($c_cache_time / $microtime_time * 100) . '%' . 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)
7.4.100.0100.00816.53
7.4.90.0220.00616.42
7.4.80.0160.01416.40
7.4.70.0090.01716.57
7.4.60.0180.01116.50
7.4.50.0200.01016.51
7.4.40.0160.01116.50
7.4.30.0200.01016.46
7.4.20.0170.01116.52
7.4.10.0130.01316.29
7.4.00.0100.01116.42
7.3.220.0160.01216.46
7.3.210.0190.01016.44
7.3.200.0200.01016.37
7.3.190.0200.00916.47
7.3.180.0260.00716.45
7.3.170.0200.01116.52
7.3.160.0190.01016.37
7.3.150.0170.01016.34
7.3.140.0120.01216.62
7.3.130.0190.00916.36
7.3.120.0150.00616.58
7.3.110.0140.00816.55
7.3.100.0090.01216.42
7.3.90.0090.01216.39
7.3.80.0140.01116.57
7.3.70.0120.00916.44
7.3.60.0160.00816.33
7.3.50.0180.00916.35
7.3.40.0090.01516.33
7.3.30.0120.00816.41
7.3.20.0120.01316.51
7.3.10.0120.00816.26
7.3.00.0090.01216.38
7.2.330.0140.01316.46
7.2.320.0160.01116.83
7.2.310.0140.01216.70
7.2.300.0130.01316.74
7.2.290.0170.01016.64
7.2.280.0170.01216.85
7.2.270.0110.01516.75
7.2.260.0150.00916.62
7.2.250.0100.01216.74
7.2.240.0070.01616.47
7.2.230.0140.01016.78
7.2.220.0130.01016.73
7.2.210.0150.00716.64
7.2.200.0120.01216.73
7.2.190.0130.01016.57
7.2.180.0100.01316.54
7.2.170.0170.00716.65
7.2.160.0140.01016.61
7.2.150.0130.01116.61
7.2.140.0120.01016.60
7.2.130.0140.00916.67
7.2.120.0250.00616.51
7.2.110.0160.01016.67
7.2.100.0130.01416.58
7.2.90.0130.00816.68
7.2.80.0140.00816.75
7.2.70.0130.01316.48
7.2.60.0070.01416.71
7.2.50.0160.01016.60
7.2.40.0070.01616.67
7.2.30.0200.01116.54
7.2.20.0140.01016.55
7.2.10.0090.01616.69
7.2.00.0100.01116.50
7.1.330.0200.01315.43
7.1.320.0130.02515.63
7.1.310.0510.00715.60
7.1.300.0190.00815.48
7.1.290.0220.00615.52
7.1.280.0290.01015.48
7.1.270.0200.01315.43
7.1.260.0190.00615.38
7.1.250.0240.00615.52
7.1.240.0150.01215.38
7.1.230.0120.01515.46
7.1.220.0190.01115.44
7.1.210.0440.00715.55
7.1.200.0220.01415.56
7.1.190.0200.01715.62
7.1.180.0220.01115.54
7.1.170.0300.01015.55
7.1.160.0220.01015.65
7.1.150.0300.00915.63
7.1.140.0210.01715.39
7.1.130.0190.01315.42
7.1.120.0230.00915.53
7.1.110.0230.01015.57
7.1.100.0220.01515.61
7.1.90.0330.00615.69
7.1.80.0200.01715.38
7.1.70.0220.01515.42
7.1.60.0220.00915.53
7.1.50.0210.01215.76
7.1.40.0270.00915.43
7.1.30.0180.01815.55
7.1.20.0530.00915.71
7.1.10.0200.01215.66
7.1.00.0220.01015.45
7.0.330.0190.00515.11
7.0.320.0170.00715.06
7.0.310.0180.01215.23
7.0.300.0230.01015.14
7.0.290.0260.01315.27
7.0.280.0200.01215.14
7.0.270.0550.01615.22
7.0.260.0260.01615.29
7.0.250.0280.00615.25
7.0.240.0190.01915.41
7.0.230.0250.01715.38
7.0.220.0230.01715.34
7.0.210.0240.01215.23
7.0.200.0230.01015.29
7.0.190.0270.01015.28
7.0.180.0240.01215.38
7.0.170.0260.00615.33
7.0.160.0260.01015.39
7.0.150.0230.01215.32
7.0.140.0180.01115.45
7.0.130.0210.00715.36
7.0.120.0220.00915.34
7.0.110.0240.00515.21
7.0.100.0350.00715.31
7.0.90.0220.00715.38
7.0.80.0240.01315.44
7.0.70.0210.01815.31
7.0.60.0220.01115.26
7.0.50.0150.01515.17
7.0.40.0200.01315.20
7.0.30.0220.01215.36
7.0.20.0210.01615.16
7.0.10.0190.01615.35
7.0.00.0270.00315.25
5.6.400.0230.00916.02
5.6.390.0230.00815.82
5.6.380.0220.01316.04
5.6.370.0160.02615.78
5.6.360.0160.02215.82
5.6.350.0200.02016.23
5.6.340.0310.01116.17
5.6.330.0270.00816.09
5.6.320.0250.01015.93
5.6.310.0100.02415.98
5.6.300.0220.01516.03
5.6.290.0200.01415.99
5.6.280.0150.01816.00
5.6.270.0210.01815.88
5.6.260.0250.00815.94
5.6.250.0210.01215.91
5.6.240.0220.01416.00
5.6.230.0190.01615.94
5.6.220.0160.01915.81
5.6.210.0200.01315.90
5.6.200.0130.02116.08
5.6.190.0140.02116.07
5.6.180.0220.01916.02
5.6.170.0200.01515.80
5.6.160.0350.00915.78
5.6.150.0230.01615.86
5.6.140.0250.00816.18
5.6.130.0150.02115.98
5.6.120.0190.01516.13
5.6.110.0160.01616.15
5.6.100.0230.00915.83
5.6.90.0230.01616.01
5.6.80.0280.00915.94
5.6.70.0230.02015.72
5.6.60.0190.02315.79
5.6.50.0320.01515.81
5.6.40.0130.02316.01
5.6.30.0160.02015.90
5.6.20.0270.01515.85
5.6.10.0310.00715.80
5.6.00.0130.02015.87
5.5.380.0270.01815.99
5.5.370.0180.02516.00
5.5.360.0280.01115.83
5.5.350.0200.01315.78
5.5.340.0220.01315.84
5.5.330.0290.01215.66
5.5.320.0230.01115.74
5.5.310.0220.01915.93
5.5.300.0160.01715.95
5.5.290.0160.01915.81
5.5.280.0180.01415.77
5.5.270.0120.02115.70
5.5.260.0190.01416.11
5.5.250.0220.01515.89
5.5.240.0190.02815.92
5.5.230.0210.02415.76
5.5.220.0230.02115.80
5.5.210.0140.02815.87
5.5.200.0290.01216.07
5.5.190.0190.02515.86
5.5.180.0220.01915.81
5.5.170.0160.01615.68
5.5.160.0150.02615.84
5.5.150.0200.01415.91
5.5.140.0210.01116.03
5.5.130.0280.00615.94
5.5.120.0160.02315.91
5.5.110.0190.01615.79
5.5.100.0200.01616.14
5.5.90.0240.00815.81
5.5.80.0190.01515.84
5.5.70.0230.01515.87
5.5.60.0360.01015.82
5.5.50.0270.01615.86
5.5.40.0170.02115.73
5.5.30.0220.01615.82
5.5.20.0210.01415.79
5.5.10.0270.01315.84
5.5.00.0180.01915.88
5.4.450.0130.01312.84
5.4.440.0150.01013.03
5.4.430.0160.01212.85
5.4.420.0130.01412.82
5.4.410.0150.01212.57
5.4.400.0170.01212.75
5.4.390.0180.01112.51
5.4.380.0220.01612.65
5.4.370.0140.01812.78
5.4.360.0160.01312.75
5.4.350.0150.01512.82
5.4.340.0170.01412.68
5.4.330.0150.01112.82
5.4.320.0130.02312.74
5.4.310.0210.00612.98
5.4.300.0210.00612.68
5.4.290.0250.01112.63
5.4.280.0210.01612.57
5.4.270.0100.01712.84
5.4.260.0140.01612.88
5.4.250.0200.01212.73
5.4.240.0100.01712.71
5.4.230.0200.00812.53
5.4.220.0130.01712.76
5.4.210.0170.01412.57
5.4.200.0170.01412.89
5.4.190.0130.01612.81
5.4.180.0100.01812.53
5.4.170.0200.00712.50
5.4.160.0110.01612.65
5.4.150.0230.00612.54
5.4.140.0140.02112.63
5.4.130.0180.01212.90
5.4.120.0150.01212.74
5.4.110.0170.01212.88
5.4.100.0200.00712.84
5.4.90.0140.01812.77
5.4.80.0110.01512.63
5.4.70.0140.01112.85
5.4.60.0170.02112.86
5.4.50.0140.01412.68
5.4.40.0100.02712.80
5.4.30.0200.01512.68
5.4.20.0160.01012.66
5.4.10.0240.00712.80
5.4.00.0180.01412.85
5.3.290.0150.01813.26
5.3.280.0190.01113.00
5.3.270.0140.01413.07
5.3.260.0230.01013.04
5.3.250.0140.01513.20
5.3.240.0160.01712.97
5.3.230.0130.02013.14
5.3.220.0160.02312.87
5.3.210.0090.02213.04
5.3.200.0170.01413.01
5.3.190.0140.01412.95
5.3.180.0160.02013.04
5.3.170.0160.01313.18
5.3.160.0110.01813.20
5.3.150.0160.01613.19
5.3.140.0160.01613.05
5.3.130.0150.01512.96
5.3.120.0190.01613.09
5.3.110.0250.00913.07
5.3.100.0160.01613.11
5.3.90.0130.01713.20
5.3.80.0190.01613.01
5.3.70.0140.01713.14
5.3.60.0130.01613.04
5.3.50.0140.02112.98
5.3.40.0200.01013.12
5.3.30.0130.02413.13
5.3.20.0150.01512.94
5.3.10.0160.01712.78
5.3.00.0180.01212.77
5.2.170.0170.01712.07
5.2.160.0160.00912.08
5.2.150.0170.00912.08
5.2.140.0140.01412.29
5.2.130.0040.02911.89
5.2.120.0140.01111.96
5.2.110.0160.01311.98
5.2.100.0170.01211.95
5.2.90.0180.01911.93
5.2.80.0150.01211.87
5.2.70.0150.01511.95
5.2.60.0130.01311.98
5.2.50.0120.01312.07
5.2.40.0130.01411.98
5.2.30.0120.02111.86
5.2.20.0110.01412.01
5.2.10.0120.02111.64
5.2.00.0140.01011.59
5.1.60.0150.00910.96
5.1.50.0130.02010.96
5.1.40.0110.01111.14
5.1.30.0150.00811.42
5.1.20.0130.01111.18
5.1.10.0160.00711.05
5.1.00.0040.01910.94
5.0.50.0150.02010.34
5.0.40.0070.02110.04
5.0.30.0100.0179.87
5.0.20.0100.0279.84
5.0.10.0130.0169.83
5.0.00.0040.0229.68
4.4.90.0080.0038.93
4.4.80.0080.0038.93
4.4.70.0050.0058.93
4.4.60.0090.0008.93
4.4.50.0090.0008.93
4.4.40.0090.0038.93
4.4.30.0050.0058.93
4.4.20.0090.0008.93
4.4.10.0000.0108.93
4.4.00.0080.0038.93
4.3.110.0030.0088.93
4.3.100.0060.0068.93
4.3.90.0090.0038.93
4.3.80.0060.0038.93
4.3.70.0060.0038.93
4.3.60.0080.0038.93
4.3.50.0060.0038.93
4.3.40.0090.0008.93
4.3.30.0050.0038.93
4.3.20.0040.0048.93
4.3.10.0000.0108.93
4.3.00.0070.0038.93

preferences:
14.85 ms | 403 KiB | 5 Q