Created
September 3, 2019 15:20
-
-
Save MegaphoneJon/3ee9d00535185dac0d4bf91b35a5f412 to your computer and use it in GitHub Desktop.
CiviCRM speed profiling script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
// How long does it take to create 10 contacts? | |
eval(`cv php:boot`); | |
\CRM_Core_Config::singleton()->doNotResetCache = 1; | |
//place this before any script you want to calculate time | |
$time_start = microtime(true); | |
$startTime = date('H:i:s'); | |
for ($i = 1; $i <= 10; $i++) { | |
echo "$i\n"; | |
$result = civicrm_api3('Contact', 'create', array( | |
'contact_id' => 3, | |
'contact_type' => 'Individual', | |
'do_not_sms' => $i % 2, | |
'skip_greeting_processing' => 1, | |
)); | |
CRM_Contact_BAO_Contact::create($params); | |
} | |
$time_end = microtime(true); | |
//dividing with 60 will give the execution time in minutes otherwise seconds | |
$execution_time = ($time_end - $time_start); | |
//execution time of the script | |
echo '<b>Total Execution Time:</b> '.$execution_time.' Seconds'; | |
------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment