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 . PHP_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; echo '+++++++++++++++++++++++++++++++++++++++' . 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.1.70.0040.00817.54
7.1.60.0030.00917.70
7.1.50.0060.00617.25
7.1.40.0000.01216.87
7.1.30.0040.00817.12
7.1.20.0080.00417.12
7.1.10.0030.00616.88
7.1.00.0110.01116.89
7.0.200.0030.00916.76
7.0.190.0000.00817.00
7.0.180.0030.00716.78
7.0.170.0040.00416.54
7.0.160.0030.00616.43
7.0.150.0000.00916.48
7.0.140.0030.00616.56
7.0.130.0000.01216.84
7.0.120.0060.00616.87
7.0.110.0060.00316.62
7.0.100.0040.00416.77
7.0.90.0000.00816.82
7.0.80.0040.00416.70
7.0.70.0030.00516.49
7.0.60.0040.00416.43
7.0.50.0110.00016.76
7.0.40.0030.00615.61
7.0.30.0030.00515.61
7.0.20.0000.00815.61
7.0.10.0040.00715.61
7.0.00.0000.00815.61
5.6.300.0170.04720.94
5.6.290.0030.04120.84
5.6.280.0100.04220.86
5.6.270.0030.04320.83
5.6.260.0000.04721.05
5.6.250.0030.05021.05
5.6.240.0030.04320.93
5.6.230.0100.03520.78
5.6.220.0070.04120.82
5.6.210.0070.05420.55
5.6.200.0030.04120.79
5.6.190.0000.04720.82
5.6.180.0100.03920.83
5.6.170.0030.04420.81
5.6.160.0060.04520.99
5.6.150.0000.06720.99
5.6.140.0030.04120.79
5.6.130.0140.04820.89
5.6.120.0030.04320.89
5.6.110.0030.04820.93
5.6.100.0060.04520.91
5.6.90.0100.03520.88
5.6.80.0070.04420.38
5.6.70.0000.04220.36
5.6.60.0070.04120.33
5.6.50.0000.04320.25
5.6.40.0030.04420.17
5.6.30.0290.03520.31
5.6.20.0130.04620.37
5.6.10.0030.04120.11
5.6.00.0030.04220.34
5.5.380.0030.06717.67
5.5.370.0070.05517.46
5.5.360.0030.04217.53
5.5.350.0030.04417.54
5.5.340.0000.04418.00
5.5.330.0060.03917.75
5.5.320.0070.04317.86
5.5.310.0000.04618.04
5.5.300.0030.04917.86
5.5.290.0030.04318.00
5.5.280.0000.04418.10
5.5.270.0000.04618.02
5.5.260.0030.04617.83
5.5.250.0000.04717.94
5.5.240.0070.04317.11
5.5.230.0100.05017.24
5.5.220.0040.03917.46
5.5.210.0000.04317.51
5.5.200.0030.04517.50
5.5.190.0030.04217.44
5.5.180.0000.04317.45
5.5.160.0040.03917.21
5.5.150.0030.03817.46
5.5.140.0040.04217.35
5.5.130.0000.04717.47
5.5.120.0000.04717.41
5.5.110.0120.03217.05
5.5.100.0030.04316.96
5.5.90.0030.03816.99
5.5.80.0000.04117.09
5.5.70.0090.04117.25
5.5.60.0070.03917.42
5.5.50.0070.03917.33
5.5.40.0060.04517.34
5.5.30.0070.03817.32
5.5.20.0090.04116.93
5.5.10.0060.03917.10
5.5.00.0030.04017.27
5.4.450.0190.05519.30
5.4.440.0030.05819.40
5.4.430.0030.04419.58
5.4.420.0070.03619.46
5.4.410.0060.03819.16
5.4.400.0000.07619.09
5.4.390.0030.04318.95
5.4.380.0070.03418.95
5.4.370.0100.07219.06
5.4.360.0040.03918.92
5.4.350.0000.04619.19
5.4.340.0070.04319.14
5.4.320.0040.03919.05
5.4.310.0000.04618.99
5.4.300.0030.03819.06
5.4.290.0070.03718.94
5.4.280.0040.03918.91
5.4.270.0030.04019.14
5.4.260.0060.04918.89
5.4.250.0030.03818.97
5.4.240.0030.04119.10
5.4.230.0030.04418.97
5.4.220.0100.03318.86
5.4.210.0100.03518.97
5.4.200.0030.04519.23
5.4.190.0110.03519.25
5.4.180.0150.03019.05
5.4.170.0100.04119.06
5.4.160.0060.03519.04
5.4.150.0110.03919.19
5.4.140.0160.04216.73
5.4.130.0090.03116.63
5.4.120.0030.03916.51
5.4.110.0060.03516.54
5.4.100.0040.04416.54
5.4.90.0040.03516.68
5.4.80.0030.03716.80
5.4.70.0060.03916.74
5.4.60.0030.05416.51
5.4.50.0030.04016.70
5.4.40.0100.03216.66
5.4.30.0070.03416.71
5.4.20.0000.04216.45
5.4.10.0040.04016.38
5.4.00.0060.03816.04
5.3.290.0070.03615.61
5.3.280.0030.04215.61
5.3.270.0030.04215.61
5.3.260.0030.03815.61
5.3.250.0000.04615.61
5.3.240.0000.04315.61
5.3.230.0030.03815.61
5.3.220.0030.04215.61
5.3.210.0030.04215.61
5.3.200.0000.04115.61
5.3.190.0040.03915.61
5.3.180.0030.03915.61
5.3.170.0030.03715.61
5.3.160.0060.03615.61
5.3.150.0040.04015.61
5.3.140.0030.04115.61
5.3.130.0000.05915.61
5.3.120.0090.03315.61
5.3.110.0070.05115.61
5.3.100.0070.05615.61
5.3.90.0040.05715.61
5.3.80.0000.03915.61
5.3.70.0070.06315.61
5.3.60.0030.03615.61
5.3.50.0030.04215.61
5.3.40.0060.06615.61
5.3.30.0030.05415.61
5.3.20.0060.03515.61
5.3.10.0130.03715.61
5.3.00.0000.04315.61

preferences:
27.1 ms | 401 KiB | 5 Q