3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thesaurus { protected $synonyms = array( array('great', 'wonderful', 'amazing', 'fabulous', 'awesome', 'stunning'), array('look', 'see', 'observe') ); public function lookup($word) { foreach ($this->synonyms as $index => $synonym) { if (in_array(strtolower($word), $synonym)) { unset($synonym[ array_search($word, $synonym) ]); return $synonym[ array_rand($synonym) ]; } } return $word; } } class Transformer { protected $thesaurus; public function __construct(Thesaurus $thesaurus) { $this->thesaurus = $thesaurus; } public function transform($string) { foreach (str_word_count($string, 1) as $word) { $string = $this->replace($word, $this->thesaurus->lookup($word), $string); } return $string; } private function replace($needle, $replacement, $haystack) { echo $needle . ' ' . $replacement . PHO_EOL; return preg_replace( '~' . preg_quote($needle, '~') . '~i', $replacement, $haystack, 1 ); } } $transformer = new Transformer(new Thesaurus); foreach (range(1, 20) as $index) { echo $transformer->transform('This is my great description. It really is wonderful. Look how wonderful it is.'), 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.00.0000.01915.39
7.3.120.0040.01314.96
7.3.110.0060.01215.18
7.3.100.0070.01415.00
7.3.90.0040.01215.38
7.3.80.0030.01015.25
7.3.70.0100.00715.17
7.3.60.0030.01315.16
7.3.50.0070.00715.17
7.3.40.0110.00814.89
7.3.30.0040.01115.20
7.3.20.0100.00717.05
7.3.10.0130.00316.70
7.3.00.0110.00716.58
7.2.250.0060.01715.18
7.2.240.0040.01415.29
7.2.230.0070.01315.14
7.2.220.0090.00915.21
7.2.210.0060.00615.29
7.2.200.0140.00315.45
7.2.190.0090.00615.24
7.2.180.0000.01415.07
7.2.170.0070.01115.21
7.2.160.0100.00615.12
7.2.150.0080.00816.81
7.2.140.0040.01216.94
7.2.130.0030.01417.27
7.2.120.0030.01317.05
7.2.110.0090.00917.31
7.2.100.0100.00617.12
7.2.90.0070.01017.23
7.2.80.0070.01117.08
7.2.70.0090.01217.36
7.2.60.0000.01817.30
7.2.50.0110.01116.97
7.2.40.0030.02217.25
7.2.30.0030.01417.32
7.2.20.0070.01317.28
7.2.10.0060.01516.79
7.2.00.0200.00016.88
7.1.330.0130.00815.98
7.1.320.0060.01216.06
7.1.310.0090.00916.27
7.1.300.0070.01015.87
7.1.290.0030.01015.88
7.1.280.0000.01616.07
7.1.270.0070.00715.82
7.1.260.0090.00615.96
7.1.250.0080.00815.83
7.1.240.0070.01015.91
7.1.230.0030.00915.75
7.1.220.0070.00416.05
7.1.210.0040.01116.06
7.1.200.0160.00316.02
7.1.190.0030.01315.98
7.1.180.0110.00716.13
7.1.170.0110.00316.15
7.1.160.0100.01015.98
7.1.150.0120.00616.04
7.1.140.0040.01515.63
7.1.130.0120.00615.76
7.1.120.0110.00415.97
7.1.110.0070.01016.01
7.1.100.0030.01316.00
7.1.90.0070.01016.19
7.1.80.0040.00715.99
7.1.70.0100.00715.66
7.1.60.0060.00915.78
7.1.50.0030.01715.93
7.1.40.0030.01416.04
7.1.30.0070.01415.77
7.1.20.0030.01015.96
7.1.10.0090.01115.82
7.1.00.0090.00915.90
7.0.330.0090.00915.65
7.0.320.0000.02115.40
7.0.310.0090.00915.62
7.0.300.0000.01615.68
7.0.290.0100.01015.38
7.0.280.0070.00715.41
7.0.270.0100.00515.33
7.0.260.0140.00415.78
7.0.250.0120.00915.51
7.0.240.0090.00615.70
7.0.230.0100.01315.48
7.0.220.0040.01315.35
7.0.210.0040.01615.78
7.0.200.0030.01215.57
7.0.190.0000.01915.56
7.0.180.0030.01215.60
7.0.170.0130.00815.85
7.0.160.0110.00415.53
7.0.150.0000.01615.75
7.0.140.0080.01015.79
7.0.130.0070.01015.66
7.0.120.0030.01615.69
7.0.110.0120.00415.70
7.0.100.0080.00415.72
7.0.90.0110.00715.58
7.0.80.0090.00915.50
7.0.70.0030.00815.70
7.0.60.0070.00715.61
7.0.50.0030.01315.70
7.0.40.0150.00413.70
7.0.30.0070.01013.77
7.0.20.0100.01013.53
7.0.10.0080.00813.73
7.0.00.0090.00913.88
5.6.400.0040.00714.35
5.6.390.0110.00414.45
5.6.380.0100.01014.34
5.6.370.0130.00314.59
5.6.360.0030.02014.34
5.6.350.0100.01014.45
5.6.340.0070.01514.43
5.6.330.0040.01514.64
5.6.320.0070.01014.67
5.6.310.0070.01414.68
5.6.300.0070.01714.20
5.6.290.0130.00614.50
5.6.280.0060.00914.66
5.6.270.0090.01314.31
5.6.260.0090.01014.42
5.6.250.0100.00614.33
5.6.240.0040.01614.59
5.6.230.0140.00414.89
5.6.220.0060.01214.68
5.6.210.0060.01014.42
5.6.200.0030.01514.40
5.6.190.0160.00314.34
5.6.180.0110.01014.71
5.6.170.0100.00614.36
5.6.160.0090.01814.63
5.6.150.0040.01514.47
5.6.140.0130.00314.45
5.6.130.0040.01814.44
5.6.120.0030.01714.63
5.6.110.0030.01614.57
5.6.100.0070.01414.22
5.6.90.0090.01214.54
5.6.80.0060.01314.60
5.6.70.0090.00914.67
5.6.60.0070.01014.51
5.6.50.0030.01314.67
5.6.40.0040.01414.54
5.6.30.0000.01514.33
5.6.20.0100.01014.46
5.6.10.0030.01314.38
5.6.00.0070.01014.65
5.5.380.0120.00914.55
5.5.370.0110.01114.36
5.5.360.0070.01014.45
5.5.350.0060.01214.30
5.5.340.0120.01214.23
5.5.330.0000.01514.54
5.5.320.0070.01114.51
5.5.310.0070.01414.36
5.5.300.0120.01014.18
5.5.290.0100.01014.54
5.5.280.0090.00614.63
5.5.270.0100.01314.55
5.5.260.0110.01414.05
5.5.250.0030.01714.32
5.5.240.0090.01414.21
5.5.230.0070.01014.28
5.5.220.0160.00314.32
5.5.210.0070.01714.36
5.5.200.0000.01514.39
5.5.190.0100.01414.08
5.5.180.0100.01414.41
5.5.170.0100.01714.52
5.5.160.0110.01414.41
5.5.150.0150.01114.27
5.5.140.0090.01214.09
5.5.130.0040.01414.46
5.5.120.0070.01414.30
5.5.110.0080.01414.04
5.5.100.0100.01414.06
5.5.90.0150.00414.22
5.5.80.0070.01714.32
5.5.70.0040.01914.48
5.5.60.0060.01414.22
5.5.50.0110.01414.23
5.5.40.0090.01514.06
5.5.30.0070.01114.32
5.5.20.0040.02114.08
5.5.10.0070.01413.98
5.5.00.0110.01114.36
5.4.450.0040.01111.01
5.4.440.0050.01110.80
5.4.430.0060.00911.36
5.4.420.0030.01511.06
5.4.410.0070.01411.31
5.4.400.0120.00310.78
5.4.390.0110.00411.00
5.4.380.0120.00411.06
5.4.370.0040.01511.10
5.4.360.0070.00711.11
5.4.350.0080.00811.10
5.4.340.0060.00911.09
5.4.330.0120.01211.03
5.4.320.0080.01511.02
5.4.310.0100.01311.23
5.4.300.0030.01910.60
5.4.290.0080.01610.89
5.4.280.0030.00811.02
5.4.270.0080.00811.01
5.4.260.0140.00710.91
5.4.250.0000.01611.16
5.4.240.0060.01211.02
5.4.230.0050.03414.90
5.4.220.0070.03414.93
5.4.210.0130.03414.76
5.4.200.0080.04814.96
5.4.190.0070.03314.93
5.4.180.0090.03514.91
5.4.170.0150.03414.68
5.4.160.0070.03914.70
5.4.150.0140.03114.89
5.4.140.0120.02813.96
5.4.130.0100.03813.88
5.4.120.0070.03813.88
5.4.110.0050.03413.57
5.4.100.0130.02913.77
5.4.90.0080.04013.77
5.4.80.0050.03913.60
5.4.70.0050.03413.75
5.4.60.0150.02713.79
5.4.50.0070.03013.73
5.4.40.0080.04013.62
5.4.30.0100.02813.60
5.4.20.0060.03713.65
5.4.10.0120.04413.77
5.4.00.0150.04013.35
5.3.290.0040.01510.94
5.3.280.0100.03112.61
5.3.270.0130.03512.68
5.3.260.0090.02912.61
5.3.250.0070.03712.60
5.3.240.0110.03412.63
5.3.230.0080.03712.62
5.3.220.0080.04012.64
5.3.210.0090.04512.57
5.3.200.0120.04512.65
5.3.190.0100.03112.50
5.3.180.0080.03312.87
5.3.170.0070.03512.85
5.3.160.0140.04012.64
5.3.150.0080.03112.73
5.3.140.0110.03012.75
5.3.130.0130.03712.67
5.3.120.0100.03212.68
5.3.110.0100.03212.66
5.3.100.0130.03212.38
5.3.90.0140.03112.41
5.3.80.0080.03812.13
5.3.70.0030.03812.37
5.3.60.0080.03512.28
5.3.50.0030.05012.37
5.3.40.0110.01110.66
5.3.30.0000.01810.43
5.3.20.0030.01410.66
5.3.10.0050.00910.50
5.3.00.0000.02110.23

preferences:
36.38 ms | 400 KiB | 5 Q