3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* */ /* * ssi_update.php * * CRON Script to directly maintain SSI's DB containing list of our members and profile survey answers. * Makes use of SSI's Bulk Import API using RESTful model to perform updates. RESTful requests made using cURL connections. * Only deletions and additons are performed. Once member is created in SSI's DB, updates are not done. * * @dependencies BatchProcessLogging, SSI, SSI_db, SSI_api * Derives from cint_update.php * @author Dave Buchanan * @version 1.0 * @created 20150227 */ require_once '_variables.php'; require_once '_classes/class.MarsImportToSsi.php'; //SSI Class for API requests ini_set( 'memory_limit', '1024M' ); // initially added to try to fix Out of Memory error set_time_limit(0); $debug=1; // 0=no echo output, just batch logging, 1=batch and echo out, 2= only echo out ///Bulk is the flag needs to be passed in like --bulk $extra_options= getopt('P:L:',array('bulk','redo')); //Decide if we're doing bulk full export to csv OR api import calls $type = (isset($extra_options['bulk'])) ? 'bulk' : 'api'; ///Special flag to redo import run, doesn't drop/create/repopulate partner tables $redo = (isset($extra_options['redo'])) ? true : false; /* Init SSI class and start logging */ $ssi = new SSI(basename(__FILE__),$debug,$cli_options['L'], $cli_options['P'],$type); $ssi->startLog(); $ssi->logComment("Started"); if($redo) { $ssi->logComment("REDO RUN!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT GOING TO DROP PREV AND RECREATE PARTNER TABLES!!"); $ssi->sendEmailAlert("REDO RUN STARTED!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT GOING TO DROP PREV AND RECREATE PARTNER TABLES!!"); } $exec_results = $ssi->alreadyRunning(); if ( (int)$exec_results[0] > 1 ) { $ssi->logComment("Process already started. Existing."); $ssi->logFinish( 'Finished: ' . $batchProcessLogging->getElapsedBatchExecutionTime(true)); exit(); } /* Init SSI Database class, pass in main SSI */ $ssi_db = new SSI_db($ssi); if($redo===false) { /* Check 1: Make sure member_partner_integration table has rows */ $check1 = $ssi_db->checkMemberPartnerIntegration(); if($check1===false) exit(0); else $ssi->logComment('Completed 1st validation, member_partner_integration not empty'); /* If exists, drop ssi_member_list_prev table and recreate from ssi_member_list */ $result = $ssi_db->dropMemberListPrev(); $result = $ssi_db->createMemberListPrev(); /* Re-create ssi_member_list from member_partner_integration. */ $result = $ssi_db->populateMemberList(); $ssi->logComment('Completed table maintainence'); /* Check 2: If counts are the same then no new members were added, something is wrong */ $check2 = $ssi_db->compareMemberListCounts(); if($check2===false) exit(0); else $ssi->logComment('Completed 2nd validation, ssi_member_list and ssi_member_list_prev counts are NOT the same'); /* Remove duplicates from Sendearnings, don't allow member email to receive surveys from both sites, inboxdollars and sendearnings */ if ($ssi->getSite() == 'sendearnings') { $ssi->logComment('Deleting duplicate members for sendearings'); $ssi_db->deleteDuplicateSEMembers(); } } else { $ssi->logComment("Redo run set, reimporting the same members! Not doing any table maintainence for ssi_member_list, ssi_member_list_prev"); } /* Get FEATURES matched in survey_partner_xref */ $result = $ssi_db->getQuestionFromSurveyPartnerXref(); ///Default 4 labels to INTEGER type question that won't exist in survey_partner_xref ///They come from survey_result_dob and member_status table $int_feature_lbls = array('postalcode','monthdob','daydob','yeardob'); $feature_lbls = array(); while( $row = mysql_fetch_assoc($result) ) { if ( !empty($row['survey_partner_question_desc']) ) array_push($feature_lbls,$row['survey_partner_question_desc']); } if($ssi->getType() == 'bulk') { $ssi->logComment("Preparing to add members to bulk csv."); $result = $ssi_db->getSurveyMembers($feature_lbls,false); ///EXPORT CSV PATH $file_name = './'.$ssi->getSite().'_export.csv'; $header = 'id,'; $header .= implode(',',$int_feature_lbls); $header .= ','.implode(',',$feature_lbls); ///Write header $z = file_put_contents($file_name,$header.PHP_EOL); } else { $ssi->logComment("Preparing to use SSI API to send members in batches"); $result = $ssi_db->getSurveyMembers($feature_lbls,true); $members = array(); $ssi_api = new SSI_api($ssi); } $total_required_features = count($feature_lbls) + count($int_feature_lbls)+1; ///Some counters to track stuff $members_skipped=0; $members_added=0; $number_of_batches=0; while( $row = mysql_fetch_assoc($result) ) { //Dont send to partner if not equal to features expected if(count($row) !== $total_required_features) { $ssi->logComment("Member ".$row['respondentid'].") doesn't have enough required features...Has ".count($row)." needs to have ".$total_required_features."."); $members_skipped++; } else { //IF bulk then append to csv, otherwise add to array and determine if ready to send a batch if($ssi->getType() == 'bulk') { $z = file_put_contents($file_name,implode(',',$row).PHP_EOL, FILE_APPEND); } else { ///Assemble json for members, member_code (respondentID) is first value while the rest should match the $feature_lbls array_push($members,array( 'respondentID'=>array_shift($row), 'values'=>array_values($row))); if(($members_added+1) % $ssi_api->getBatchCount() === 0) { $batch_result = $ssi_api->sendBatch($members,array_merge($int_feature_lbls,$feature_lbls)); ///If batch result isn't false add failed submissions to members skipped, else add current count of members $members_skipped = ($batch_result!=false) ? $members_skipped + $batch_result : $members_skipped+count($members); $number_of_batches++; ///Reset array for next batch $members = array(); } } $members_added++; } } /* END loop through members */ $ssi_db->freeResult($result); $total_sent = $members_added-$members_skipped; if($ssi->getType()!='bulk') { $ssi->logComment("Ran ".$number_of_batches." batches. Total of $members_added members to $type export. $members_skipped members skipped, total sent=$total_sent"); } else { $ssi->logComment("Added $members_added members to $type export. $members_skipped members skipped, total sent=$total_sent"); } $ssi->sendEmailFinish("Completed! $type...$members_added members added. $members_skipped members skipped, total sent=$total_sent"); $ssi->endLog("Finished $type import."); // END ASSEMBLING JSON TO SEND TO SSI // ***************************************************************************///

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.60.0120.00916.61
8.3.50.0120.01022.00
8.3.40.0040.01119.09
8.3.30.0110.00419.01
8.3.20.0090.00020.25
8.3.10.0040.00421.90
8.3.00.0080.00019.29
8.2.180.0100.01317.00
8.2.170.0040.01122.96
8.2.160.0090.00521.98
8.2.150.0060.00324.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0080.00019.65
8.2.110.0030.00622.02
8.2.100.0090.00318.03
8.2.90.0080.00019.36
8.2.80.0030.00617.97
8.2.70.0060.00317.75
8.2.60.0040.00718.05
8.2.50.0060.00318.07
8.2.40.0080.00018.15
8.2.30.0000.00719.61
8.2.20.0040.00417.76
8.2.10.0050.00318.27
8.2.00.0040.00417.76
8.1.280.0070.00725.92
8.1.270.0030.00618.96
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00323.79
8.1.230.0080.00419.36
8.1.220.0060.00317.74
8.1.210.0090.00018.77
8.1.200.0030.00617.35
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0030.00618.68
8.1.160.0040.00422.11
8.1.150.0030.00619.01
8.1.140.0060.00317.46
8.1.130.0040.00217.86
8.1.120.0000.00717.46
8.1.110.0040.00417.48
8.1.100.0000.00717.52
8.1.90.0020.00517.55
8.1.80.0000.00817.54
8.1.70.0000.00717.43
8.1.60.0040.00417.63
8.1.50.0000.01117.68
8.1.40.0060.00317.70
8.1.30.0000.00817.82
8.1.20.0030.00517.75
8.1.10.0040.00417.63
8.1.00.0030.00517.53
8.0.300.0040.00418.77
8.0.290.0030.00616.88
8.0.280.0030.00318.60
8.0.270.0030.00417.46
8.0.260.0080.00017.39
8.0.250.0030.00617.11
8.0.240.0040.00417.13
8.0.230.0070.00017.13
8.0.220.0000.00717.17
8.0.210.0030.00317.16
8.0.200.0000.00817.26
8.0.190.0080.00017.18
8.0.180.0060.00317.23
8.0.170.0040.00417.11
8.0.160.0030.00517.16
8.0.150.0030.00517.06
8.0.140.0050.00217.11
8.0.130.0030.00313.61
8.0.120.0060.00317.18
8.0.110.0040.00417.12
8.0.100.0040.00417.04
8.0.90.0040.00416.99
8.0.80.0070.01017.18
8.0.70.0000.00717.27
8.0.60.0030.00517.14
8.0.50.0080.00017.05
8.0.30.0150.00917.13
8.0.20.0080.01117.40
8.0.10.0070.00317.05
8.0.00.0120.00616.88
7.4.330.0050.00015.05
7.4.320.0030.00316.77
7.4.300.0070.00016.75
7.4.290.0000.00716.78
7.4.280.0040.00416.64
7.4.270.0000.00716.63
7.4.260.0000.01016.58
7.4.250.0080.00016.66
7.4.240.0030.00516.68
7.4.230.0000.00716.67
7.4.220.0140.00916.66
7.4.210.0110.00716.65
7.4.200.0070.00016.67
7.4.160.0140.00316.62
7.4.150.0120.00617.40
7.4.140.0110.00817.86
7.4.130.0100.00716.60
7.4.120.0120.00616.56
7.4.110.0130.01016.59
7.4.100.0160.00316.64
7.4.90.0080.01116.43
7.4.80.0140.00719.39
7.4.70.0070.01116.36
7.4.60.0120.00616.53
7.4.50.0000.00416.36
7.4.40.0040.01216.52
7.4.30.0100.00716.82
7.4.10.0030.01315.31
7.4.00.0130.00515.03
7.3.330.0000.00613.23
7.3.320.0030.00313.15
7.3.310.0000.00816.35
7.3.300.0000.00816.39
7.3.290.0030.00316.42
7.3.280.0100.00716.36
7.3.270.0140.00617.40
7.3.260.0120.00616.34
7.3.250.0100.00916.41
7.3.240.0080.01616.62
7.3.230.0110.00716.52
7.3.210.0130.00316.46
7.3.200.0030.01419.39
7.3.190.0090.01216.33
7.3.180.0120.00316.33
7.3.170.0100.01016.61
7.3.160.0090.00916.36
7.3.130.0090.00914.71
7.3.120.0040.01314.79
7.3.110.0030.01314.74
7.3.100.0040.01114.92
7.3.90.0060.01114.86
7.3.80.0050.00414.91
7.3.70.0080.00514.90
7.3.60.0030.00914.94
7.3.50.0060.00614.88
7.3.40.0070.00914.93
7.3.30.0070.00814.97
7.3.20.0060.00816.46
7.3.10.0020.01016.59
7.3.00.0040.00916.55
7.2.330.0060.01216.66
7.2.320.0110.00616.64
7.2.310.0120.00616.49
7.2.300.0090.01416.74
7.2.290.0070.01116.63
7.2.260.0080.00814.68
7.2.250.0100.00715.10
7.2.240.0050.01114.78
7.2.230.0050.00714.95
7.2.220.0070.00715.02
7.2.210.0020.01414.98
7.2.200.0050.01115.02
7.2.190.0100.00714.98
7.2.180.0070.00515.14
7.2.170.0080.00614.91
7.2.160.0060.00614.78
7.2.150.0050.01316.74
7.2.140.0060.00916.69
7.2.130.0070.00516.85
7.2.120.0060.00816.80
7.2.110.0040.00916.85
7.2.100.0100.00716.71
7.2.90.0060.00616.82
7.2.80.0050.00816.48
7.2.70.0060.00916.95
7.2.60.0060.00716.55
7.2.50.0060.00816.78
7.2.40.0090.00716.79
7.2.30.0030.01116.85
7.2.20.0100.00516.83
7.2.10.0070.01016.66
7.2.00.0070.00717.52
7.1.330.0080.00615.73
7.1.320.0080.00815.59
7.1.310.0020.01115.47
7.1.300.0050.01115.68
7.1.290.0050.01015.67
7.1.280.0000.01015.66
7.1.270.0050.00815.66
7.1.260.0070.00915.60
7.1.250.0050.01015.67
7.1.240.0040.00815.66
7.1.230.0000.01215.70
7.1.220.0030.01015.59
7.1.210.0030.00615.40
7.1.200.0050.00615.69
7.1.190.0030.00915.64
7.1.180.0080.00315.61
7.1.170.0000.01315.68
7.1.160.0070.01015.63
7.1.150.0030.00615.62
7.1.140.0030.01015.75
7.1.130.0030.00715.40
7.1.120.0000.00915.74
7.1.110.0000.01115.54
7.1.100.0060.00616.71
7.1.90.0030.00615.67
7.1.80.0060.00915.64
7.1.70.0000.01216.24
7.1.60.0080.01017.56
7.1.50.0080.01016.28
7.1.40.0030.00615.69
7.1.30.0070.00715.39
7.1.20.0030.00915.69
7.1.10.0040.00715.62
7.1.00.0050.04218.95
7.0.330.0030.01015.09
7.0.320.0030.00815.31
7.0.310.0100.00314.85
7.0.300.0100.00315.04
7.0.290.0000.00915.33
7.0.280.0070.00415.29
7.0.270.0060.00615.19
7.0.260.0070.00315.36
7.0.250.0040.00715.40
7.0.240.0080.00415.23
7.0.230.0060.00315.20
7.0.220.0030.00715.15
7.0.210.0060.00615.16
7.0.200.0010.01015.79
7.0.190.0000.00915.07
7.0.180.0030.01015.11
7.0.170.0040.01115.12
7.0.160.0060.00315.19
7.0.150.0090.00015.35
7.0.140.0050.03818.55
7.0.130.0090.00315.13
7.0.120.0030.00915.05
7.0.110.0030.00615.20
7.0.100.0050.04517.51
7.0.90.0030.03517.62
7.0.80.0020.04717.72
7.0.70.0120.02317.66
7.0.60.0070.04117.60
7.0.50.0060.02517.70
7.0.40.0070.04116.72
7.0.30.0030.02516.77
7.0.20.0020.05016.68
7.0.10.0040.02316.66
7.0.00.0090.03516.56
5.6.400.0080.00414.23
5.6.390.0060.00914.41
5.6.380.0090.00614.14
5.6.370.0060.00614.12
5.6.360.0070.01014.14
5.6.350.0040.01214.13
5.6.340.0080.00414.11
5.6.330.0080.00014.31
5.6.320.0040.00414.04
5.6.310.0100.00314.07
5.6.300.0090.00014.23
5.6.290.0070.00713.89
5.6.280.0050.03817.52
5.6.270.0070.00713.98
5.6.260.0030.01314.29
5.6.250.0050.04217.44
5.6.240.0100.03817.55
5.6.230.0070.04217.26
5.6.220.0110.03817.42
5.6.210.0050.04317.37
5.6.200.0060.02517.55
5.6.190.0060.04617.70
5.6.180.0060.04617.73
5.6.170.0050.04017.52
5.6.160.0050.03817.67
5.6.150.0060.04817.77
5.6.140.0090.04117.59
5.6.130.0020.03117.66
5.6.120.0050.03917.72
5.6.110.0090.03517.42
5.6.100.0100.02217.59
5.6.90.0030.02617.50
5.6.80.0040.02417.44
5.6.70.0030.02317.25
5.6.60.0080.03217.17
5.6.50.0120.04017.30
5.6.40.0070.03417.21
5.6.30.0030.04017.18
5.6.20.0030.02517.27
5.6.10.0040.04117.28
5.6.00.0080.01917.27
5.5.380.0040.04817.22
5.5.370.0070.04117.34
5.5.360.0030.03817.13
5.5.350.0070.02817.19
5.5.340.0030.02717.39
5.5.330.0050.04717.41
5.5.320.0050.04217.38
5.5.310.0110.04017.53
5.5.300.0050.04817.24
5.5.290.0080.02217.44
5.5.280.0160.03617.54
5.5.270.0050.04317.55
5.5.260.0080.03017.65
5.5.250.0030.04417.29
5.5.240.0060.02617.13
5.5.230.0040.03316.96
5.5.220.0020.02917.22
5.5.210.0070.04217.09
5.5.200.0050.02917.21
5.5.190.0050.04517.28
5.5.180.0060.02517.19
5.5.170.0070.00313.70
5.5.160.0020.03116.95
5.5.150.0020.03117.16
5.5.140.0100.04317.05
5.5.130.0120.04117.26
5.5.120.0070.02517.00
5.5.110.0060.03317.12
5.5.100.0080.04017.11
5.5.90.0070.04017.08
5.5.80.0150.03617.06
5.5.70.0110.02016.99
5.5.60.0050.04216.82
5.5.50.0050.02416.92
5.5.40.0070.04216.97
5.5.30.0070.03117.05
5.5.20.0070.02017.12
5.5.10.0100.03817.17
5.5.00.0070.04016.84
5.4.450.0050.03715.12
5.4.440.0090.03915.07
5.4.430.0050.04015.18
5.4.420.0110.03615.11
5.4.410.0030.02215.16
5.4.400.0040.02214.86
5.4.390.0050.02814.81
5.4.380.0070.03214.92
5.4.370.0100.03814.77
5.4.360.0030.02914.81
5.4.350.0060.02014.92
5.4.340.0050.02314.72
5.4.330.0030.00310.47
5.4.320.0020.03714.95
5.4.310.0080.03314.89
5.4.300.0030.04014.79
5.4.290.0020.02714.90
5.4.280.0020.04714.78
5.4.270.0060.03014.82
5.4.260.0090.03915.01
5.4.250.0070.01914.89
5.4.240.0020.02914.81
5.4.230.0010.02514.82
5.4.220.0050.02414.74
5.4.210.0020.04414.80
5.4.200.0050.03714.87
5.4.190.0020.03114.95
5.4.180.0060.03814.83
5.4.170.0040.02714.97
5.4.160.0030.04214.91
5.4.150.0060.02814.88
5.4.140.0050.01813.35
5.4.130.0050.02013.62
5.4.120.0030.02813.67
5.4.110.0090.04313.63
5.4.100.0100.03513.50
5.4.90.0030.03013.47
5.4.80.0040.01913.54
5.4.70.0020.03713.64
5.4.60.0000.03113.49
5.4.50.0030.03713.61
5.4.40.0030.02313.60
5.4.30.0070.02513.60
5.4.20.0020.02413.61
5.4.10.0050.03613.51
5.4.00.0010.04313.25

preferences:
59.41 ms | 401 KiB | 5 Q