3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** strrev function implementation taken from ext/standard/string.c PHP-5-5 branch http://lxr.php.net/xref/PHP_5_5/ext/standard/string.c#3165 // {{{ proto string strrev(string str) // Reverse a string PHP_FUNCTION(strrev) { char *str; char *e, *n, *p; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { return; } n = emalloc(str_len+1); p = n; e = str + str_len; while (--e>=str) { *p++ = *e; } *p = '\0'; RETVAL_STRINGL(n, str_len, 0); } // }}} */ // PHP Implementation function userland_strrev($string) { if (!is_string($string)) { return false; } $new_string = ""; $len = strlen($string); while (--$len) { $new_string .= $string[$len]; } return $new_string; } $string = "Hello PHP!"; var_dump(strrev($string), userland_strrev($string)); /* for ($i = 0; $i < $n; $i++) { $t = microtime(true); $php[] = microtime(true) - $t; } */

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.40.0120.00318.65
8.3.30.0030.01018.80
8.3.20.0040.00420.26
8.3.10.0080.00023.60
8.3.00.0030.00519.38
8.2.170.0110.00322.96
8.2.160.0100.00320.43
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00819.76
8.2.110.0060.00320.42
8.2.100.0060.00617.91
8.2.90.0030.00619.24
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0000.00817.93
8.2.50.0080.00018.34
8.2.40.0030.00520.59
8.2.30.0000.00721.15
8.2.20.0050.00317.80
8.2.10.0060.00318.17
8.2.00.0000.00817.71
8.1.270.0130.00323.96
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0090.00022.23
8.1.230.0110.00017.65
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0060.00317.23
8.1.180.0000.00819.98
8.1.170.0040.00418.74
8.1.160.0040.00418.94
8.1.150.0070.00020.07
8.1.140.0000.00817.35
8.1.130.0000.00717.83
8.1.120.0040.00417.41
8.1.110.0040.00417.48
8.1.100.0000.00717.50
8.1.90.0000.00717.45
8.1.80.0000.00817.35
8.1.70.0030.00317.41
8.1.60.0070.00017.61
8.1.50.0050.00317.45
8.1.40.0040.00417.54
8.1.30.0040.00417.63
8.1.20.0000.00717.53
8.1.10.0050.00217.43
8.1.00.0080.00017.55
8.0.300.0040.00418.77
8.0.290.0070.00016.75
8.0.280.0000.00818.34
8.0.270.0030.00317.12
8.0.260.0030.00317.09
8.0.250.0070.00016.93
8.0.240.0050.00516.99
8.0.230.0030.00316.91
8.0.220.0030.00316.93
8.0.210.0030.00316.86
8.0.200.0030.00316.86
8.0.190.0000.00716.93
8.0.180.0040.00416.92
8.0.170.0040.00416.83
8.0.160.0000.00716.86
8.0.150.0030.00716.71
8.0.140.0050.00316.89
8.0.130.0030.00313.33
8.0.120.0080.00016.80
8.0.110.0050.00316.91
8.0.100.0070.00016.71
8.0.90.0050.00316.81
8.0.80.0090.00616.84
8.0.70.0050.00316.85
8.0.60.0040.00416.92
8.0.50.0070.00016.85
8.0.30.0100.00917.08
8.0.20.0130.00917.40
8.0.10.0000.00816.90
8.0.00.0120.00616.80
7.4.330.0060.00015.00
7.4.320.0030.00316.43
7.4.300.0030.00316.54
7.4.290.0030.00316.50
7.4.280.0000.00816.48
7.4.270.0070.00016.53
7.4.260.0030.00516.41
7.4.250.0040.00416.58
7.4.240.0020.00616.45
7.4.230.0000.00716.53
7.4.220.0030.01616.41
7.4.210.0090.00716.57
7.4.200.0040.00416.62
7.4.190.0040.00416.38
7.4.160.0090.00916.78
7.4.150.0130.00317.40
7.4.140.0070.01017.86
7.4.130.0080.00816.59
7.4.120.0130.00416.46
7.4.110.0100.00716.65
7.4.100.0130.00616.48
7.4.90.0130.01016.55
7.4.80.0140.00819.39
7.4.70.0170.00016.49
7.4.60.0070.01016.48
7.4.50.0060.00316.56
7.4.40.0050.01416.23
7.4.30.0140.00716.41
7.4.10.0060.00915.00
7.4.00.0110.00514.94
7.3.330.0030.00313.32
7.3.320.0060.00013.29
7.3.310.0000.00716.40
7.3.300.0000.00616.18
7.3.290.0060.00916.26
7.3.280.0030.01516.30
7.3.270.0140.00517.40
7.3.260.0140.01016.26
7.3.250.0110.01116.36
7.3.240.0100.00616.13
7.3.230.0090.00616.39
7.3.210.0050.01116.33
7.3.200.0120.01119.39
7.3.190.0130.00316.45
7.3.180.0000.01616.35
7.3.170.0040.01216.34
7.3.160.0070.01416.55
7.3.130.0100.00715.00
7.3.120.0050.01214.84
7.3.110.0130.00614.94
7.3.100.0070.01014.83
7.3.90.0070.00714.84
7.3.80.0060.00614.68
7.3.70.0070.00714.88
7.3.60.0000.00914.48
7.3.50.0070.00714.91
7.3.40.0000.01414.86
7.3.30.0070.00715.00
7.3.20.0090.00616.79
7.3.10.0070.00716.52
7.3.00.0070.00616.84
7.2.330.0120.00616.80
7.2.320.0100.00716.61
7.2.310.0030.01416.79
7.2.300.0090.01216.80
7.2.290.0030.01416.46
7.2.260.0060.01214.68
7.2.250.0030.01315.07
7.2.240.0070.00715.13
7.2.230.0060.01215.27
7.2.220.0070.01115.05
7.2.210.0090.00315.23
7.2.200.0070.01014.94
7.2.190.0080.00415.05
7.2.180.0120.00014.88
7.2.170.0030.01014.97
7.2.160.0000.01115.18
7.2.150.0070.00716.71
7.2.140.0030.00617.09
7.2.130.0030.01217.02
7.2.120.0000.01417.04
7.2.110.0000.01716.94
7.2.100.0040.00816.77
7.2.90.0030.01316.88
7.2.80.0060.01016.75
7.2.70.0060.00317.08
7.2.60.0180.00816.87
7.2.50.0030.00816.96
7.2.40.0060.00617.00
7.2.30.0060.00617.12
7.2.20.0030.01017.03
7.2.10.0120.00317.05
7.2.00.0060.00518.02
7.1.330.0040.01115.95
7.1.320.0040.00715.75
7.1.310.0070.00315.62
7.1.300.0150.00315.77
7.1.290.0040.00715.47
7.1.280.0090.00615.97
7.1.270.0070.00715.86
7.1.260.0060.00615.88
7.1.250.0090.00615.57
7.1.240.0030.01015.79
7.1.230.0070.00715.84
7.1.220.0100.00315.73
7.1.210.0030.01415.78
7.1.200.0070.00815.83
7.1.190.0000.01115.82
7.1.180.0070.00715.88
7.1.170.0060.01015.95
7.1.160.0110.00415.75
7.1.150.0030.00915.97
7.1.140.0140.00015.92
7.1.130.0070.00715.86
7.1.120.0000.01315.90
7.1.110.0120.00315.91
7.1.100.0470.01016.15
7.1.90.0030.01215.48
7.1.80.0030.00615.59
7.1.70.0040.00616.51
7.1.60.0080.01117.66
7.1.50.0060.00916.30
7.1.40.0100.00715.74
7.1.30.0030.00615.82
7.1.20.0040.01115.81
7.1.10.0000.01415.79
7.1.00.0060.03919.16
7.0.330.0030.01015.53
7.0.320.0040.00415.26
7.0.310.0130.00315.45
7.0.300.0090.00315.39
7.0.290.0050.00515.43
7.0.280.0000.01115.44
7.0.270.0060.00915.66
7.0.260.0030.00615.33
7.0.250.0060.00315.34
7.0.240.0070.01115.57
7.0.230.0040.01215.29
7.0.220.0070.00715.51
7.0.210.0070.00715.41
7.0.200.0170.00615.00
7.0.190.0040.01115.53
7.0.180.0070.00715.36
7.0.170.0060.00315.34
7.0.160.0040.00815.60
7.0.150.0030.00815.57
7.0.140.0030.04518.73
7.0.130.0030.00615.39
7.0.120.0120.00315.32
7.0.110.0030.00715.55
7.0.100.0040.00915.50
7.0.90.0040.00415.37
7.0.80.0100.00315.57
7.0.70.0030.01015.37
7.0.60.0070.03917.76
7.0.50.0060.02216.80
7.0.40.0110.03116.83
7.0.30.0120.03016.92
7.0.20.0160.03516.74
7.0.10.0140.03916.76
7.0.00.0070.03516.81
5.6.400.0040.00714.69
5.6.390.0090.00614.41
5.6.380.0030.00914.25
5.6.370.0040.00414.54
5.6.360.0000.01214.46
5.6.350.0060.00614.78
5.6.340.0040.00714.37
5.6.330.0040.00714.28
5.6.320.0040.01114.55
5.6.310.0030.00513.93
5.6.300.0030.00914.30
5.6.290.0080.00814.21
5.6.280.0120.03317.74
5.6.270.0060.00613.91
5.6.260.0060.00614.54
5.6.250.0080.00414.05
5.6.240.0030.01014.53
5.6.230.0100.00014.02
5.6.220.0040.01114.19
5.6.210.0110.04017.44
5.6.200.0100.01816.25
5.6.190.0150.03217.41
5.6.180.2050.02717.36
5.6.170.0100.03017.33
5.6.160.0100.02517.52
5.6.150.0100.03516.13
5.6.140.0100.04216.31
5.6.130.0090.04016.03
5.6.120.0030.02717.74
5.6.110.0050.04817.50
5.6.100.0070.04417.58
5.6.90.0020.03017.79
5.6.80.0060.03917.50
5.6.70.2130.02517.37
5.6.60.0110.00414.21
5.6.50.0080.00414.29
5.6.40.0140.00014.25
5.6.30.0060.00614.01
5.6.20.0060.00614.19
5.6.10.0000.01013.96
5.6.00.0040.01114.33
5.5.380.0030.00714.36
5.5.370.0040.00714.22
5.5.360.0070.00714.26
5.5.350.0080.02217.39
5.5.340.0100.03515.89
5.5.330.0020.03117.06
5.5.320.0200.03717.25
5.5.310.0240.03517.22
5.5.300.0070.03616.14
5.5.290.0070.04516.28
5.5.280.0070.03217.45
5.5.270.0030.02417.58
5.5.260.0020.02717.65
5.5.250.0060.04117.42
5.5.240.0120.04017.21
5.5.230.0040.00814.29
5.5.220.0000.01214.08
5.5.210.0040.00413.77
5.5.200.0060.00914.45
5.5.190.0060.00914.06
5.5.180.0150.00314.39
5.5.170.0030.00713.93
5.5.160.0080.00414.41
5.5.150.0080.00414.39
5.5.140.0100.00514.46
5.5.130.0070.00714.38
5.5.120.0070.00714.26
5.5.110.0060.01114.58
5.5.100.0030.00914.11
5.5.90.0030.01214.08
5.5.80.0080.01114.05
5.5.70.0050.01114.34
5.5.60.0060.00614.19
5.5.50.0070.00714.10
5.5.40.0100.01013.98
5.5.30.0000.00814.24
5.5.20.0070.00714.05
5.5.10.0030.00714.19
5.5.00.0000.00914.11
5.4.450.0320.03415.61
5.4.440.0380.02815.48
5.4.430.0430.03515.65
5.4.420.0500.03315.51
5.4.410.0150.03015.37
5.4.400.0460.02615.40
5.4.390.0070.03015.27
5.4.380.0130.02915.07
5.4.370.0200.02615.24
5.4.360.0210.03215.21
5.4.350.0210.02515.18
5.4.340.0180.02715.22
5.4.330.0000.00711.67
5.4.320.0080.01812.09
5.4.310.0080.02212.09
5.4.300.0040.02212.09
5.4.290.0080.02812.08
5.4.280.0070.02112.03
5.4.270.0050.02112.03
5.4.260.0060.02112.03
5.4.250.0020.02512.03
5.4.240.0020.02312.03
5.4.230.0050.02212.02
5.4.220.0030.02312.02
5.4.210.0100.01712.02
5.4.200.0060.02712.02
5.4.190.0050.02012.02
5.4.180.0050.02212.02
5.4.170.0060.01812.02
5.4.160.0080.02112.02
5.4.150.0050.02412.02
5.4.140.0040.02311.87
5.4.130.0070.01911.86
5.4.120.0030.02211.84
5.4.110.0020.02311.84
5.4.100.0050.02811.83
5.4.90.0020.02611.84
5.4.80.0080.01911.83
5.4.70.0060.01911.83
5.4.60.0040.02011.83
5.4.50.0050.01911.83
5.4.40.0060.01911.83
5.4.30.0040.02211.82
5.4.20.0080.02011.82
5.4.10.0060.01911.83
5.4.00.0050.02211.57
5.3.290.0060.02212.24
5.3.280.0060.02412.19
5.3.270.0060.03112.20
5.3.260.0090.02812.20
5.3.250.0110.02012.20
5.3.240.0060.02312.20
5.3.230.0050.02212.19
5.3.220.0060.02212.18
5.3.210.0060.02412.18
5.3.200.0060.02012.18
5.3.190.0020.02512.17
5.3.180.0060.01912.17
5.3.170.0060.02112.17
5.3.160.0090.01812.17
5.3.150.0100.01712.17
5.3.140.0020.02212.17
5.3.130.0060.02012.17
5.3.120.0050.02312.16
5.3.110.0050.02412.16
5.3.100.0030.02211.90
5.3.90.0070.02011.88
5.3.80.0060.02711.88
5.3.70.0060.02711.88
5.3.60.0050.02111.87
5.3.50.0040.02111.85
5.3.40.0050.02211.85
5.3.30.0040.02311.83
5.3.20.0040.02011.71
5.3.10.0060.01811.70
5.3.00.0060.01811.70
5.2.170.0070.0439.21
5.2.160.0040.0369.22
5.2.150.0070.0289.22
5.2.140.0040.0319.21
5.2.130.0030.0309.18
5.2.120.0060.0279.17
5.2.110.0040.0299.18
5.2.100.0060.0279.17
5.2.90.0090.0259.18
5.2.80.0070.0299.17
5.2.70.0060.0299.17
5.2.60.0060.0299.13
5.2.50.0080.0279.10
5.2.40.0080.0259.08
5.2.30.0000.0389.04
5.2.20.0050.0299.04
5.2.10.0070.0278.94
5.2.00.0050.0308.80
5.1.60.0030.0258.09
5.1.50.0060.0268.08
5.1.40.0060.0228.06
5.1.30.0050.0248.41
5.1.20.0040.0308.43
5.1.10.0040.0288.16
5.1.00.0060.0248.17
5.0.50.0050.0196.64
5.0.40.0050.0176.50
5.0.30.0030.0316.31
5.0.20.0020.0206.28
5.0.10.0030.0206.26
5.0.00.0030.0316.25
4.4.90.0040.0234.78
4.4.80.0030.0234.75
4.4.70.0050.0144.75
4.4.60.0030.0154.75
4.4.50.0030.0164.77
4.4.40.0040.0254.71
4.4.30.0050.0144.76
4.4.20.0020.0164.84
4.4.10.0040.0144.85
4.4.00.0030.0254.75
4.3.110.0010.0184.67
4.3.100.0040.0144.66
4.3.90.0030.0144.64
4.3.80.0050.0244.59
4.3.70.0020.0154.63
4.3.60.0060.0164.63
4.3.50.0030.0184.62
4.3.40.0030.0244.54
4.3.30.0020.0203.30
4.3.20.0010.0183.27
4.3.10.0020.0223.24
4.3.00.0100.03310.55

preferences:
51.19 ms | 400 KiB | 5 Q