3v4l.org

run code in 300+ PHP versions simultaneously
<?php // : counter: create 0 , does> dup @ tuck 1+ swap ! ; // counter: fred ok // fred // <1> 140599575159712 // After does> // <2> 140599575159712 140599575159712 // After dup // <2> 140599575159712 0 // After @ // <3> 0 140599575159712 0 // After tuck // <3> 0 140599575159712 1 // After 1+ // <3> 0 1 140599575159712 // After swap // <1> 0 // After ! global $__STACK; $__STACK = []; function dup() { error_log('dup'); global $__STACK; $top = reset($__STACK); array_push($__STACK, $top); } function at() { error_log('at'); global $__STACK; $top = array_pop($__STACK); array_push($__STACK, $top->cell); } function tuck() { error_log('tuck'); global $__STACK; $top = array_pop($__STACK); $second = array_pop($__STACK); array_push($__STACK, $top); array_push($__STACK, $second); array_push($__STACK, $top); } function swap() { error_log('swap'); global $__STACK; $top = array_pop($__STACK); $second = array_pop($__STACK); array_push($__STACK, $top); array_push($__STACK, $second); } function store() { error_log('store'); global $__STACK; $address = array_pop($__STACK); $value = array_pop($__STACK); $address->cell = $value; } function one_plus() { error_log('one_plus'); global $__STACK; $top = array_pop($__STACK); $top++; array_push($__STACK, $top); } class counter { public $cell = 0; public function __invoke() { global $__STACK; error_log('counter::__invoke'); array_push($__STACK, $this); dup(); at(); tuck(); one_plus(); swap(); store(); } } $fred = new counter(); $fred(); $fred(); $fred(); var_dump($__STACK);

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.0140.00516.73
8.5.00.0100.01020.16
8.4.160.0150.00623.94
8.4.150.0030.00014.05
8.4.140.0090.01217.57
8.4.130.0140.00717.79
8.4.120.0070.00122.36
8.4.110.0070.00222.53
8.4.100.0160.01017.87
8.4.90.0110.01017.89
8.4.80.0110.00817.79
8.4.70.0090.01317.92
8.4.60.0120.01017.95
8.4.50.0070.01322.23
8.4.40.0120.00617.64
8.4.30.0100.01020.32
8.4.20.0140.00718.12
8.4.10.0060.00319.48
8.3.280.0110.01018.46
8.3.270.0180.00216.66
8.3.260.0100.01016.70
8.3.250.0120.00618.97
8.3.240.0120.00716.86
8.3.230.0080.00416.63
8.3.220.0110.00717.16
8.3.210.0050.00317.00
8.3.200.0110.00816.91
8.3.190.0060.01316.78
8.3.180.0100.00916.46
8.3.170.0090.00920.76
8.3.160.0060.01218.60
8.3.150.0060.00316.99
8.3.140.0120.00617.21
8.3.130.0110.00418.55
8.3.120.0090.00019.04
8.3.110.0090.00620.94
8.3.100.0040.01124.06
8.3.90.0040.00426.77
8.3.80.0050.00518.68
8.3.70.0080.00816.63
8.3.60.0150.00616.75
8.3.50.0140.00718.80
8.3.40.0070.00722.10
8.3.30.0110.00721.98
8.3.20.0060.00924.18
8.3.10.0070.00024.66
8.3.00.0070.00026.16
8.2.290.0100.01120.50
8.2.280.0050.00318.66
8.2.270.0090.00916.56
8.2.260.0090.00618.45
8.2.250.0050.00317.06
8.2.240.0030.00717.28
8.2.230.0130.00322.58
8.2.220.0060.00337.54
8.2.210.0080.00026.77
8.2.200.0100.00316.50
8.2.190.0120.00916.88
8.2.180.0130.00616.88
8.2.170.0150.00618.79
8.2.160.0030.01422.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00319.13
8.2.110.0000.01022.25
8.2.100.0000.01120.61
8.2.90.0110.00618.91
8.2.80.0110.00318.63
8.2.70.0120.00618.68
8.2.60.0120.00618.77
8.2.50.0160.00318.76
8.2.40.0100.00718.56
8.2.30.0090.00618.79
8.2.20.0140.00318.89
8.2.10.0090.01219.08
8.2.00.0120.00418.91
8.1.330.0120.00716.92
8.1.320.0110.00916.38
8.1.310.0000.00918.61
8.1.300.0100.01017.95
8.1.290.0090.00030.84
8.1.280.0200.00025.92
8.1.270.0040.00423.99
8.1.260.0070.00028.09
8.1.250.0070.00028.09
8.1.240.0180.01418.48
8.1.230.0070.01118.58
8.1.220.0060.00918.67
8.1.210.0090.00619.73
8.1.200.0080.00818.42
8.1.190.0120.00618.52
8.1.180.0170.00718.46
8.1.170.0150.00018.48
8.1.160.0090.00618.75
8.1.150.0110.00320.55
8.1.140.0080.00818.41
8.1.130.0110.00618.54
8.1.120.0240.00718.19
8.1.110.0120.00318.36
8.1.100.0120.00618.37
8.1.90.0250.00418.50
8.1.80.0230.00718.23
8.1.70.0130.00318.66
8.1.60.0180.00618.75
8.1.50.0160.00618.63
8.1.40.0120.00318.73
8.1.30.0070.00719.05
8.1.20.0070.01118.63
8.1.10.0110.00418.75
8.1.00.0100.00518.63
8.0.300.0100.00717.80
8.0.290.0160.00317.80
8.0.280.0150.00617.73
8.0.270.0290.00717.83
8.0.260.0280.00417.72
8.0.250.0290.00317.92
8.0.240.0210.01417.96
8.0.230.0250.00918.09
8.0.220.0210.01417.96
8.0.210.0270.00717.73
8.0.200.0320.00717.83
8.0.190.0250.00017.89
8.0.180.0170.00317.88
8.0.170.0180.01417.62
8.0.160.0240.01717.94
8.0.150.0310.00717.83
8.0.140.0280.00617.59
8.0.130.0130.01717.87
8.0.120.0260.00617.82
8.0.110.0160.00618.06
8.0.100.0320.00617.88
8.0.90.0110.00817.70
8.0.80.0320.00717.71
8.0.70.0300.01017.83
8.0.60.0250.00617.75
8.0.50.0250.00917.75
8.0.30.0180.00017.93
8.0.20.0300.00817.68
8.0.10.0330.00618.19

preferences:
37.47 ms | 403 KiB | 5 Q