3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Water { public $color = 'clear'; public $temp = 'cold'; } // Lets make some pipes $color_water_blue_pipe = function (Water $water, callable $next_pipe) { $water->color = 'blue'; // We colored it, now we're done. Send it to the next pipe and return the result! return $next_pipe($water); }; $heat_water_pipe = function (Water $water, callable $next_pipe) { $water->temp = 'hot'; // We heated it, send it to the next pipe! return $next_pipe($water); }; // Make some water $water = new Water(); // Create our pipeline $pipeline = (new Pipeline()) ->send($water) ->through([ $color_water_blue_pipe, $heat_water_pipe ]) ->then(function($water) { return $water; }); // Run it $piped_water = $pipeline->execute(); echo "The water is {$piped_water->color} and {$piped_water->temp}!"; #### Pipeline dependency class Pipeline { /** * @var array The parameters to pass through */ protected $parameters = []; /** * @var \Closure[] The list of pipes that the parameters will fall through * Pipe should match function($parameter..., \Closure $next) {} */ protected $pipes = []; /** * @type \Closure The "then" closure, it will receive the parameters you pipe through */ protected $thenClosure; /** * @inheritdoc */ public function send(...$parameters) : Pipeline { $this->parameters = $parameters; return $this; } /** * @inheritdoc */ public function through($pipes) : Pipeline { $this->pipes = is_array($pipes) ? $pipes : func_get_args(); return $this; } /** * @inheritdoc */ public function then(callable $then) : Pipeline { $this->thenClosure = $then; return $this; } /** * @inheritdoc */ public function execute() { $pipes = array_reverse($this->pipes); /** @type \Closure $linked_closure */ $linked_closure = array_reduce($pipes, $this->getIterator(), $this->getInitial($this->thenClosure)); return $linked_closure(...$this->parameters); } /** * Get the iterator closure, this wraps every item in the list and injects the * @return \Closure */ protected function getIterator() : \Closure { return function ($next, $pipe) { return function (...$parameters) use ($next, $pipe) { $parameters[] = $next; return $pipe(...$parameters); }; }; } /** * The initial closure * @return \Closure */ protected function getInitial(\Closure $then) : \Closure { return function(...$parameters) use ($then) { return $then(...$parameters); }; } }

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.3.60.0110.00416.88
8.3.50.0110.00822.05
8.3.40.0110.00418.97
8.3.30.0070.00718.70
8.3.20.0090.00020.40
8.3.10.0030.00721.52
8.3.00.0080.00021.76
8.2.180.0070.00716.50
8.2.170.0150.00022.96
8.2.160.0040.01120.47
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0040.00420.77
8.2.120.0000.00826.35
8.2.110.0060.00319.32
8.2.100.0080.00417.93
8.2.90.0000.00819.36
8.2.80.0080.00017.97
8.2.70.0000.00917.50
8.2.60.0080.00018.04
8.2.50.0000.00818.09
8.2.40.0040.00422.20
8.2.30.0040.00419.55
8.2.20.0060.00317.70
8.2.10.0060.00318.16
8.2.00.0070.00018.22
8.1.280.0090.00925.92
8.1.270.0030.00522.14
8.1.260.0060.00328.09
8.1.250.0080.00028.09
8.1.240.0100.00022.23
8.1.230.0080.00317.70
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0060.00317.22
8.1.190.0030.00617.35
8.1.180.0030.00518.10
8.1.170.0040.00418.64
8.1.160.0000.00720.87
8.1.150.0000.00718.93
8.1.140.0040.00419.61
8.1.130.0000.00717.73
8.1.120.0040.00417.44
8.1.110.0030.00517.47
8.1.100.0000.00817.38
8.1.90.0000.00717.38
8.1.80.0000.00817.44
8.1.70.0030.00317.45
8.1.60.0000.00817.57
8.1.50.0030.00617.49
8.1.40.0080.00017.61
8.1.30.0060.00317.67
8.1.20.0000.00817.69
8.1.10.0030.00617.53
8.1.00.0040.00417.58
8.0.300.0000.00818.77
8.0.290.0000.00816.88
8.0.280.0040.00418.50
8.0.270.0000.00716.97
8.0.260.0000.00817.35
8.0.250.0030.00317.11
8.0.240.0040.00416.96
8.0.230.0000.00716.95
8.0.220.0000.00716.88
8.0.210.0040.00417.02
8.0.200.0050.00316.95
8.0.190.0030.00517.13
8.0.180.0000.00817.04
8.0.170.0040.00417.01
8.0.160.0070.00016.98
8.0.150.0040.00416.98
8.0.140.0040.00416.94
8.0.130.0000.00613.46
8.0.120.0040.00416.88
8.0.110.0040.00416.96
8.0.100.0000.00716.85
8.0.90.0040.00417.00
8.0.80.0090.00616.96
8.0.70.0000.00716.82
8.0.60.0050.00316.92
8.0.50.0000.00716.95
8.0.30.0150.00717.07
8.0.20.0080.01017.42
8.0.10.0040.00417.10
8.0.00.0110.00616.81
7.4.330.0000.00516.87
7.4.320.0040.00416.70
7.4.300.0000.00716.65
7.4.290.0070.00016.48
7.4.280.0040.00416.56
7.4.270.0000.00716.55
7.4.260.0040.00416.45
7.4.250.0030.00516.52
7.4.240.0040.00416.57
7.4.230.0000.00716.41
7.4.220.0030.01616.68
7.4.210.0080.00716.62
7.4.200.0080.00016.39
7.4.160.0080.00816.66
7.4.150.0110.00817.40
7.4.140.0140.00717.86
7.4.130.0080.01016.52
7.4.120.0120.00516.52
7.4.110.0070.01016.67
7.4.100.0090.00916.69
7.4.90.0100.00716.58
7.4.80.0080.01219.39
7.4.70.0130.00716.41
7.4.60.0150.00516.57
7.4.50.0060.01016.48
7.4.40.0100.00716.54
7.4.30.0090.01516.54
7.4.10.0090.00914.71
7.4.00.0090.00915.02
7.3.330.0050.00313.30
7.3.320.0060.00013.27
7.3.310.0070.00016.30
7.3.300.0030.00316.26
7.3.290.0040.00416.36
7.3.280.0090.00916.36
7.3.270.0140.00317.40
7.3.260.0100.00616.41
7.3.250.0150.00316.43
7.3.240.0080.00916.52
7.3.230.0060.01216.57
7.3.210.0100.00716.59
7.3.200.0090.01319.39
7.3.190.0140.00316.59
7.3.180.0120.00616.39
7.3.170.0100.00716.54
7.3.160.0060.01116.37
7.3.130.0060.01215.00
7.3.120.0090.00914.81
7.3.110.0080.00814.85
7.3.100.0090.00715.06
7.3.90.0040.00914.64
7.3.80.0110.00514.79
7.3.70.0050.00614.73
7.3.60.0080.00814.88
7.3.50.0050.00714.88
7.3.40.0070.00814.92
7.3.30.0050.00614.70
7.3.20.0060.00916.82
7.3.10.0090.00616.60
7.3.00.0050.00916.58
7.2.330.0150.00316.91
7.2.320.0120.00916.93
7.2.310.0080.00816.46
7.2.300.0130.00316.55
7.2.290.0110.01116.66
7.2.260.0030.01315.41
7.2.250.0110.00614.92
7.2.240.0070.00915.21
7.2.230.0060.01015.13
7.2.220.0040.01015.21
7.2.210.0100.00514.88
7.2.200.0040.00915.26
7.2.190.0070.00715.09
7.2.180.0000.01515.00
7.2.170.0080.00615.03
7.2.160.0100.00715.16
7.2.150.0080.01117.03
7.2.140.0090.00917.00
7.2.130.0110.00516.77
7.2.120.0070.00816.87
7.2.110.0090.00616.89
7.2.100.0090.00416.81
7.2.90.0050.01116.79
7.2.80.0050.01216.98
7.2.70.0000.01216.90
7.2.60.0060.00717.02
7.2.50.0030.01217.00
7.2.40.0020.01517.02
7.2.30.0040.00916.97
7.2.20.0070.01017.01
7.2.10.0020.00816.83
7.2.00.0070.00917.78
7.1.330.0050.00815.79
7.1.320.0040.00615.80
7.1.310.0050.01015.85
7.1.300.0020.01215.74
7.1.290.0050.00615.85
7.1.280.0030.00815.79
7.1.270.0050.01115.65
7.1.260.0080.00915.91
7.1.250.0050.00715.67
7.1.240.0090.00615.95
7.1.230.0060.01015.95
7.1.220.0070.01015.86
7.1.210.0030.00615.77
7.1.200.0060.00915.86
7.1.190.0040.01515.98
7.1.180.0000.00815.46
7.1.170.0000.01415.57
7.1.160.0100.00316.03
7.1.150.0100.00315.81
7.1.140.0000.00915.71
7.1.130.0030.01015.61
7.1.120.0070.00715.66
7.1.110.0000.00915.59
7.1.100.0050.00517.00
7.1.90.0030.00715.84
7.1.80.0130.00015.93
7.1.70.0030.00716.47
7.1.60.0100.00817.68
7.1.50.0030.01216.41
7.1.40.0000.00916.03
7.1.30.0060.00315.81
7.1.20.0040.00815.77
7.1.10.0120.00015.98
7.1.00.0050.04319.14
7.0.330.0070.00415.15
7.0.320.0030.01015.21
7.0.310.0030.01215.21
7.0.300.0030.01415.46
7.0.290.0000.01115.23
7.0.280.0070.00715.47
7.0.270.0040.00715.60
7.0.260.0040.01115.46
7.0.250.0000.01215.40
7.0.240.0030.01015.29
7.0.230.0100.00315.57
7.0.220.0080.00415.43
7.0.210.0060.00915.22
7.0.200.0020.00815.89
7.0.190.0100.00315.52
7.0.180.0030.01015.45
7.0.170.0040.00415.54
7.0.160.0090.00615.49
7.0.150.0070.01115.46
7.0.140.0030.00715.11
7.0.130.0070.00715.53
7.0.120.0100.00315.46
7.0.110.0070.00615.22
7.0.100.0070.00715.45
7.0.90.0030.01015.46
7.0.80.0090.00915.61
7.0.70.0000.01115.43
7.0.60.0190.04317.77
7.0.50.0030.02916.59
7.0.40.0050.02516.92
7.0.30.0220.04016.65
7.0.20.0070.03116.86
7.0.10.0120.04416.83
7.0.00.0060.02316.87
5.6.400.0060.00614.35
5.6.390.0000.01214.25
5.6.380.0060.00913.98
5.6.370.0030.01414.32
5.6.360.0110.00314.36
5.6.350.0000.01014.10
5.6.340.0030.00914.07
5.6.330.0120.00314.30
5.6.320.0070.00714.10
5.6.310.0060.00314.39
5.6.300.0040.00713.92
5.6.290.0030.01014.39
5.6.280.0020.02217.38
5.6.270.0060.00914.21
5.6.260.0060.00614.09
5.6.250.0040.01114.39
5.6.240.0040.01414.29
5.6.230.0070.00713.98
5.6.220.0070.00414.03
5.6.210.0090.03817.53
5.6.200.0090.04216.19
5.6.190.0040.02617.39
5.6.180.0150.02417.29
5.6.170.0150.02117.23
5.6.160.0060.03517.33
5.6.150.0090.04116.32
5.6.140.0110.03016.15
5.6.130.0030.03016.07
5.6.120.0070.02517.54
5.6.110.0080.04517.73
5.6.100.0070.04817.67
5.6.90.0000.02817.48
5.6.80.0070.04217.30
5.6.70.0070.00413.92
5.6.60.0090.00614.28
5.6.50.0060.00813.92
5.6.40.0030.00514.11
5.6.30.0030.00514.13
5.6.20.0040.00813.92
5.6.10.0040.00814.16
5.6.00.0100.00313.92
5.5.380.0030.00714.17
5.5.370.0050.00514.38
5.5.360.0060.00614.45
5.5.350.0140.02617.28
5.5.340.0080.03916.13
5.5.330.0060.04317.33
5.5.320.0130.02417.18
5.5.310.0150.03017.16
5.5.300.0050.02516.13
5.5.290.0120.04016.06
5.5.280.0080.02617.49
5.5.270.0050.04517.50
5.5.260.0120.03217.46
5.5.250.0070.03617.38
5.5.240.0080.02017.25
5.5.230.0040.00414.35
5.5.220.0030.00613.95
5.5.210.0000.01413.64
5.5.200.0060.00814.05
5.5.190.0030.01014.00
5.5.180.0000.01214.03
5.5.170.0040.00413.67
5.5.160.0030.01013.55
5.5.150.0060.00614.13
5.5.140.0060.00914.14
5.5.130.0030.01214.01
5.5.120.0120.00614.08
5.5.110.0090.00913.98
5.5.100.0070.01113.97
5.5.90.0000.01713.68
5.5.80.0040.00813.80
5.5.70.0060.00613.84
5.5.60.0060.00614.13
5.5.50.0090.00614.05
5.5.40.0070.00713.85
5.5.30.0030.01213.79
5.5.20.0120.00013.85
5.5.10.0070.00713.97
5.5.00.0080.00313.96

preferences:
68.61 ms | 401 KiB | 5 Q