Skip to content

Instantly share code, notes, and snippets.

@joelhandwell
Last active October 21, 2015 14:35
Show Gist options
  • Save joelhandwell/9c5d92ade8233de6a4d2 to your computer and use it in GitHub Desktop.
Save joelhandwell/9c5d92ade8233de6a4d2 to your computer and use it in GitHub Desktop.
PHP Speed Profile Recording Syslog Example
<?php
function do_something1(){
//speed profiling for A
$beforeA = microtime(true);
executeA();
$afterA = microtime(true);
if (($afterA-$beforeA)>400){
$eA = new Exception;
syslog(LOG_INFO, "spent ".($afterA-$beforeA).' '.$eA->getTraceAsString();
}
}
function do_something1(){
//speed pofiling for B
$beforeB = microtime(true);
executeB();
$afterB = microtime(true);
if (($afterB-$beforeB)>400){
$eB = new Exception;
syslog(LOG_INFO, "spent ".($afterB-$beforeB).' '.$eB->getTraceAsString();
}
//speed profiling for C
$beforeC = microtime(true);
executeC();
$afterC = microtime(true);
if (($afterC-$beforeC)>400){
$eC = new Exception;
syslog(LOG_INFO, "spent ".($afterC-$beforeC).' '.$eC->getTraceAsString();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment