3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_to_anon_object($arr): object { $obj = new class {}; foreach ( $arr as $key => $value ) { $obj->{$key} = $value; } return $obj; } class EmptyClass {} function array_to_normal_object($arr, $className): object { $obj = new class {}; foreach ( $arr as $key => $value ) { $obj->{$key} = $value; } return $obj; } var_dump( json_encode([1,2,3]) ); var_dump( json_encode((object)[1,2,3]) ); var_dump( json_encode(array_to_anon_object([1,2,3])) ); var_dump( json_encode(array_to_normal_object([1,2,3], EmptyClass::class)) ); var_dump( json_encode(array_to_normal_object([1,2,3], stdClass::class)) );

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.70.0070.02016.58
8.3.60.0000.01916.75
8.3.50.0060.01216.28
8.3.40.0070.01022.00
8.3.30.0030.01418.68
8.3.20.0080.00024.18
8.3.10.0100.00024.66
8.3.00.0050.00226.16
8.2.180.0110.00725.92
8.2.170.0060.00918.94
8.2.160.0140.00022.96
8.2.150.0050.00325.66
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0060.00320.39
8.2.110.0070.00320.52
8.2.100.0090.00317.78
8.2.90.0000.00817.88
8.2.80.0080.00018.91
8.2.70.0080.00017.75
8.2.60.0080.00017.50
8.2.50.0040.00417.63
8.2.40.0000.00819.47
8.2.30.0030.00519.35
8.2.20.0050.00217.98
8.2.10.0000.00719.16
8.2.00.0000.00719.37
8.1.280.0040.01225.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0100.00021.99
8.1.230.0040.00822.75
8.1.220.0090.00018.70
8.1.210.0000.00818.77
8.1.200.0040.00417.11
8.1.190.0040.00417.22
8.1.180.0040.00418.10
8.1.170.0000.00817.62
8.1.160.0050.00219.05
8.1.150.0040.00418.91
8.1.140.0040.00418.91
8.1.130.0000.00720.17
8.1.120.0040.00417.39
8.1.110.0000.00817.41
8.1.100.0020.00517.46
8.1.90.0040.00417.32
8.1.80.0000.01117.49
8.1.70.0040.00417.50
8.1.60.0080.00017.63
8.1.50.0040.00417.44
8.1.40.0000.00817.43
8.1.30.0030.00517.55
8.1.20.0040.00417.72
8.1.10.0000.00817.57
8.1.00.0040.00417.43
8.0.300.0000.00818.77
8.0.290.0050.00316.88
8.0.280.0040.00418.46
8.0.270.0030.00316.92
8.0.260.0030.00320.28
8.0.250.0030.00317.02
8.0.240.0000.00817.05
8.0.230.0030.00316.95
8.0.220.0000.00716.87
8.0.210.0030.00316.95
8.0.200.0030.00617.07
8.0.190.0030.00616.92
8.0.180.0020.00517.07
8.0.170.0000.00817.03
8.0.160.0050.00316.95
8.0.150.0000.00716.98
8.0.140.0040.00416.83
8.0.130.0050.00013.38
8.0.120.0030.00516.93
8.0.110.0000.00716.86
8.0.100.0070.00016.93
8.0.90.0040.00416.88
8.0.80.0030.01417.00
8.0.70.0000.00716.88
8.0.60.0040.00416.95
8.0.50.0000.00716.82
8.0.30.0060.01016.96
8.0.20.0100.01017.25
8.0.10.0000.00717.07
8.0.00.0070.01116.79
7.4.330.0040.00015.55
7.4.320.0000.00816.64
7.4.300.0070.00316.48
7.4.290.0070.00016.48
7.4.280.0040.00416.55
7.4.270.0000.00716.53
7.4.260.0030.00313.36
7.4.250.0030.00516.41
7.4.240.0070.00016.57
7.4.230.0030.00316.40
7.4.220.0000.00716.63
7.4.210.0070.01016.59
7.4.200.0070.00016.38
7.4.130.0110.00616.58
7.4.120.0180.00416.59
7.4.110.0110.00516.37
7.4.100.0160.00616.19
7.4.90.0180.00016.26
7.4.80.0170.00616.29
7.4.70.0050.01916.56
7.4.60.0110.00616.49
7.4.50.0120.00616.43
7.4.40.0130.00616.34
7.4.30.0110.01116.23
7.4.20.0040.01616.60
7.4.10.0140.00316.36
7.4.00.0130.00416.53
7.3.330.0030.00316.45
7.3.320.0030.00313.39
7.3.310.0000.00716.39
7.3.300.0070.00016.30
7.3.290.0070.00616.36
7.3.260.0110.01216.61
7.3.230.0030.01216.38
7.3.220.0100.00716.43
7.3.210.0000.01716.33
7.3.200.0110.00716.52
7.3.190.0100.00716.56
7.3.180.0070.01016.23
7.3.170.0060.01116.58
7.3.160.0080.00816.38
7.3.150.0110.01216.42
7.3.140.0110.00816.37
7.3.130.0030.01416.50
7.3.120.0100.01316.53
7.3.110.0030.01316.45
7.3.100.0100.01016.36
7.3.90.0150.00716.63
7.3.80.0090.01316.16
7.3.70.0090.01216.37
7.3.60.0120.00616.41
7.3.50.0060.01216.41
7.3.40.0130.00616.36
7.3.30.0180.00316.30
7.3.20.0100.00716.43
7.3.10.0060.01316.52
7.3.00.0150.00416.27
7.2.340.0040.01316.47
7.2.330.0170.00716.69
7.2.320.0160.00816.70
7.2.310.0070.01016.43
7.2.300.0070.01016.75
7.2.290.0070.01116.94
7.2.280.0120.01216.71
7.2.270.0100.01016.48
7.2.260.0050.01116.72
7.2.250.0100.01316.46
7.2.240.0130.01016.44
7.2.230.0100.01416.53
7.2.220.0150.01016.52
7.2.210.0130.01016.65
7.2.200.0160.00316.55
7.2.190.0100.00716.65
7.2.180.0100.00616.40
7.2.170.0130.00716.61
7.2.160.0140.00416.54
7.2.150.0120.00616.73
7.2.140.0140.00616.80
7.2.130.0140.00416.64
7.2.120.0100.00716.57
7.2.110.0140.00316.71
7.2.100.0090.00916.72
7.2.90.0150.00316.63
7.2.80.0090.00916.71
7.2.70.0130.00316.68
7.2.60.0060.01216.78
7.2.50.0190.00016.72
7.2.40.0060.01316.70
7.2.30.0030.01416.63
7.2.20.0040.01316.66
7.2.10.0080.00816.68
7.2.00.0110.00816.66

preferences:
52.23 ms | 401 KiB | 5 Q