3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); // Make a bit, honkin test array // You may need to adjust this depth to avoid memory limit errors $testArray = [ 'string' => 'string', 'int' => 1, 'float' => 1.1, 'bool' => true, 'date' => new Datetime('now'), 'array' => [ 'string' => 'string', 'int' => 1, 'float' => 1.1, 'bool' => true, 'date' => new Datetime('now'), 'array' => [ 'string' => 'string', 'int' => 1, 'float' => 1.1, 'bool' => true, 'date' => new Datetime('now'), ], ], fillArray(0, 5) ]; $numRuns = 10000000; // Time json encoding $start = microtime( true ); for ($i = 0; $i++; $i <= $numRuns) { json_encode( $testArray ); } $jsonTime = (microtime( true ) - $start); echo "JSON encoded in " . ($jsonTime/$numRuns) . " seconds\n"; // Time serialization $start = microtime( true ); for ($i = 0; $i++; $i <= $numRuns) { serialize( $testArray ); } $serializeTime = (microtime( true ) - $start); echo "PHP serialized in " . ($serializeTime/$numRuns) . " seconds\n"; // Compare them if ( $jsonTime < $serializeTime ) { echo "json_encode() was roughly " . number_format( ($serializeTime / $jsonTime - 1 ) * 100, 2 ) . "% faster than serialize()"; } else if ( $serializeTime < $jsonTime ) { echo "serialize() was roughly " . ($serializeTime ? number_format( ($jsonTime / $serializeTime - 1) * 100, 2 ) . '%' : 'insanely') . " faster than json_encode()"; } else { echo 'This is a draw'; } function fillArray( $depth, $max ) { static $seed; if ( is_null( $seed ) ) { $seed = array( 'a', 2, 'c', 4, 'e', 6, 'g', 8, 'i', 10 ); } if ( $depth < $max ) { $node = array(); foreach ( $seed as $key ) { $node[$key] = fillArray( $depth + 1, $max ); } return $node; } return 'empty'; }

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.4.20.0490.02125.37
8.4.10.0410.01625.33
8.3.190.0210.01224.21
8.3.150.0190.01224.33
8.3.140.0320.02124.13
8.3.130.0330.02723.95
8.3.120.0500.00624.00
8.3.110.0410.01623.80
8.3.100.0450.01823.88
8.3.90.0370.01524.31
8.3.80.0440.02923.93
8.3.70.0330.02123.93
8.3.60.0440.01824.56
8.3.50.0290.01324.56
8.3.40.0200.01725.38
8.3.30.0300.01325.23
8.3.20.0290.01325.36
8.3.10.0440.01425.17
8.3.00.0370.01125.34
8.2.270.0190.00824.08
8.2.260.0220.01824.02
8.2.250.0310.01724.17
8.2.240.0380.01924.14
8.2.230.0400.01724.20
8.2.220.0310.02123.88
8.2.210.0280.01224.13
8.2.200.0320.01123.79
8.2.190.0310.02223.85
8.2.180.0330.02224.55
8.2.170.0530.00925.29
8.2.160.0400.02325.52
8.2.150.0280.02125.40
8.2.140.0480.01225.34
8.2.130.0320.01525.38
8.2.120.0360.01725.32
8.2.110.0320.01625.51
8.2.100.0240.02225.53
8.2.90.0350.01825.41
8.2.80.0380.02425.35
8.2.70.0300.01725.32
8.2.60.0320.01525.54
8.2.50.0310.02225.50
8.2.40.0430.01725.55
8.2.30.0370.01525.35
8.2.20.0400.01425.47
8.2.10.0360.00925.30
8.2.00.0300.01825.39
8.1.310.0200.03023.73
8.1.300.0200.01424.02
8.1.290.0250.00823.78
8.1.280.0290.01524.48
8.1.270.0290.01725.26
8.1.260.0300.02325.38
8.1.250.0330.02025.29
8.1.240.0280.01125.40
8.1.230.0300.01225.35
8.1.220.0390.01525.35
8.1.210.0310.02125.09
8.1.200.0350.01525.31
8.1.190.0310.01325.20
8.1.180.0320.00825.14
8.1.170.0360.01825.18
8.1.160.0260.01525.34
8.1.150.0290.01225.16
8.1.140.0270.01725.31
8.1.130.0290.01425.20
8.1.120.0360.01425.21
8.1.110.0210.01625.25
8.1.100.0230.01525.22
8.1.90.0280.01425.30
8.1.80.0260.01525.27
8.1.70.0330.02225.20
8.1.60.0330.00825.29
8.1.50.0380.01525.36
8.1.40.0360.01825.26
8.1.30.0420.01025.30
8.1.20.0320.01325.39
8.1.10.0310.01925.31
8.1.00.0260.01625.24

preferences:
27.74 ms | 403 KiB | 5 Q