3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 1件のコメントをINSERTする function insert_comment_single( $comment, $is_table_lock ){ try { $dbh = db_open(); if ( $is_table_lock ) { // テーブルロックを実行 $sql = 'LOCK TABLES tbl_comments WRITE, tbl_relations WRITE, tbl_tags WRITE'; $db->query( $sql ); } // INSERTする $sql = 'INSERT ...'; $db->query( $sql ); // エラー確認 if ( 何かエラーなら ) throw new Exception('何かエラーです'); // エラーなければコミット if ( $is_table_lock ) $dbh->commit(); // 戻り値 $result = [ 'status' => 'ok', 'inserted_id' => 1 ]; } catch (Exception $e) { // エラーならロールバック if ( $is_table_lock ) $dbh->rollback(); // 戻り値 $result = [ 'status' => 'error', 'message' => $e->getMessage() ]; } return $result; } // 複数のコメントをINSERTする function insert_comment_multiple( $comment_arr, $is_table_lock ){ try { $dbh = db_open(); if ( $is_table_lock ) { // テーブルロックを実行 $sql = 'LOCK TABLES tbl_comments WRITE, tbl_relations WRITE, tbl_tags WRITE'; $db->query($sql); // 当関数でロックしたので single の方ではロックしない $is_table_lock2 = false; } // ループ結果 $inserted_arr = []; // single の結果 $error_index_arr = []; // エラー番号 // ループで single を実行してINSERTする foreach( $comment_arr as $index => $comment ){ $inserted = insert_comment_single( $comment, $is_table_lock2 ); // エラー番号をセット if ( $inserted['status'] === 'error' ) $error_index_arr[] = $index; // single の結果をセット $inserted_arr[] = $inserted; } // 当関数でテーブルロックした場合、1件でもエラーのときは throw でロールバック if ( $is_table_lock && !empty($error_index_arr) ) throw new Exception( implode(',',$error_index_arr) . 'でエラー'); // エラーなければコミット if ( $is_table_lock ) $dbh->commit(); // 戻り値 $result = [ 'status' =>'ok', 'inserted_arr' => $inserted_arr ]; // 当関数でテーブルロックしない場合、エラー番号を入れる if ( !$is_table_lock && !empty($error_index_arr) ) $result['error_index_arr'] = $error_index_arr; } catch (Exception $e) { // エラーならロールバック if ( $is_table_lock ) $dbh->rollback(); // 戻り値 $result = [ 'status' => 'error', 'inserted_arr' => $inserted_arr, 'message' => $e->getMessage() ]; } return $result; }

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.5.00.0070.00322.91
8.4.150.0030.00014.05
8.4.140.0140.00717.31
8.4.130.0100.00817.78
8.4.120.0120.00822.28
8.4.110.0050.00618.88
8.4.100.0140.00417.43
8.4.90.0070.01420.75
8.4.80.0040.00319.02
8.4.70.0080.00820.53
8.4.60.0120.01020.57
8.4.50.0110.00922.23
8.4.40.0080.00417.99
8.4.30.0100.01020.46
8.4.20.0140.00717.97
8.4.10.0120.00321.82
8.3.280.0010.00014.05
8.3.270.0130.00616.63
8.3.260.0110.00816.40
8.3.250.0090.00918.98
8.3.240.0120.00716.82
8.3.230.0090.00916.52
8.3.220.0110.00720.54
8.3.210.0060.00216.64
8.3.200.0050.00416.50
8.3.190.0130.00518.96
8.3.180.0090.00518.70
8.3.170.0110.00717.05
8.3.160.0090.00916.64
8.3.150.0120.00616.55
8.3.140.0110.00418.79
8.3.130.0040.00416.67
8.3.120.0120.00418.84
8.3.110.0030.00616.75
8.3.100.0100.01016.81
8.3.90.0000.00826.77
8.3.80.0100.00016.75
8.3.70.0060.00916.58
8.3.60.0070.01116.63
8.3.50.0140.00320.15
8.3.40.0110.00422.03
8.3.30.0120.00818.51
8.3.20.0000.00824.18
8.3.10.0040.00424.66
8.3.00.0000.00726.16
8.2.290.0100.00920.70
8.2.280.0090.00919.99
8.2.270.0040.01416.30
8.2.260.0110.00717.02
8.2.250.0040.00418.52
8.2.240.0100.01016.49
8.2.230.0030.00620.94
8.2.220.0040.00424.06
8.2.210.0040.00426.77
8.2.200.0060.00316.63
8.2.190.0120.00916.63
8.2.180.0110.00425.92
8.2.170.0100.01018.68
8.2.160.0100.00322.96
8.2.150.0070.00025.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0140.00021.00
8.2.110.0070.00320.94
8.2.100.0070.00719.63
8.2.90.0030.00517.97
8.2.80.0060.00619.08
8.2.70.0000.00817.50
8.2.60.0030.00617.50
8.2.50.0050.00317.98
8.2.40.0060.00318.16
8.2.30.0000.00818.09
8.2.20.0040.00420.36
8.2.10.0000.00818.05
8.2.00.0090.00019.05
8.1.330.0110.00916.99
8.1.320.0110.00922.00
8.1.310.0100.00616.38
8.1.300.0000.01017.71
8.1.290.0060.00630.84
8.1.280.0120.00625.92
8.1.270.0060.00323.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00422.02
8.1.230.0080.00322.81
8.1.220.0000.00817.74
8.1.210.0000.01018.77
8.1.200.0060.00317.10
8.1.190.0050.00517.10
8.1.180.0030.00618.10
8.1.170.0080.00017.62
8.1.160.0040.00418.77
8.1.150.0030.00618.56
8.1.140.0000.00717.22
8.1.130.0070.00018.81
8.1.120.0070.00017.40
8.1.110.0040.00417.34
8.1.100.0000.00717.38
8.1.90.0030.00617.25
8.1.80.0110.00517.39
8.1.70.0060.01017.24
8.1.60.0150.00417.57
8.1.50.0180.00017.46
8.1.40.0130.00417.34
8.1.30.0140.00417.53
8.1.20.0090.00817.53
8.1.10.0140.00317.48
8.1.00.0180.00017.43
8.0.300.0040.00419.85
8.0.290.0030.00616.75
8.0.280.0030.00318.38
8.0.270.0000.00716.80
8.0.260.0000.00618.28
8.0.250.0030.00316.92
8.0.240.0000.00716.95
8.0.230.0060.00316.88
8.0.220.0070.00016.84
8.0.210.0160.00016.79
8.0.200.0030.01216.86
8.0.190.0060.00616.80
8.0.180.0040.00816.73
8.0.170.0090.00416.78
8.0.160.0100.00516.88
8.0.150.0160.00016.65
8.0.140.0110.00416.75
8.0.130.0130.00316.70
8.0.120.0130.00316.64
8.0.110.0160.00016.75
8.0.100.0120.00316.78
8.0.90.0150.00016.65
8.0.80.0110.00416.74
8.0.70.0090.00616.79
8.0.60.0130.00316.75
8.0.50.0100.00516.66
8.0.30.0150.00016.76
8.0.20.0050.00816.75
8.0.10.0090.00516.88
7.4.330.0030.00315.55
7.4.320.0000.00716.49
7.4.300.0050.00316.43
7.4.290.0100.00716.46
7.4.280.0130.00216.44
7.4.270.0100.00016.51
7.4.260.0070.00716.38
7.4.250.0090.00316.43
7.4.240.0070.00516.42
7.4.230.0000.01016.38
7.4.220.0100.00316.50
7.4.210.0080.00516.41
7.4.200.0090.00416.47
7.4.190.0090.00516.60
7.4.180.0090.00316.43
7.4.160.0080.00516.35
7.4.150.0070.00416.36
7.4.140.0000.01216.40
7.4.130.0070.00716.20
7.4.120.0090.00016.09
7.4.110.0000.01116.26
7.4.100.0050.00516.41
7.4.90.0070.00416.37
7.4.80.0080.00416.18
7.4.70.0040.00816.35
7.4.60.0110.00416.27
7.4.50.0080.00516.25
7.4.40.0000.00916.13
7.4.30.0030.00616.23
7.4.20.0080.00616.29
7.4.10.0080.00416.08
7.4.00.0040.00416.25

preferences:
42.48 ms | 403 KiB | 5 Q