Last active
August 20, 2021 11:39
-
-
Save Luxato/f723a195161c6fc7d82a36704e0740c2 to your computer and use it in GitHub Desktop.
Magento 1 get profiler ordered by elapsed time
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
<?php | |
/* | |
* Don't forget that in order for profiler to work it has to be enabled, else you will get empty profiles. | |
*/ | |
$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler(); | |
$queryProfiles = $profiler->getQueryProfiles(); | |
$profiles = []; | |
foreach ($queryProfiles as $profile) { | |
$tmp = (array) $profile; | |
$tmp['total'] = number_format($profile->getElapsedSecs(), 5); | |
$profiles[] = $tmp; | |
} | |
$total = array_column($profiles, 'total'); | |
array_multisort($total, SORT_DESC, $profiles); | |
echo '<pre>'; | |
print_r( $profiles ); | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment