Skip to content

Instantly share code, notes, and snippets.

@MegaphoneJon
Created September 3, 2019 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MegaphoneJon/3ee9d00535185dac0d4bf91b35a5f412 to your computer and use it in GitHub Desktop.
Save MegaphoneJon/3ee9d00535185dac0d4bf91b35a5f412 to your computer and use it in GitHub Desktop.
CiviCRM speed profiling script
#!/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