Magento2 – How to enable profiler for our custom script in magento2.
We will also measure the time execution for our custom script. Just for example, i have added below script which will return the store id with custom profiler. To find out the time measurement, have added custom profiler before & after my script. Which will return the time measurement of the script.
Sample Script:
\Magento\Framework\Profiler::start(‘script-optimization-profiler‘);
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $_objectManager->get(‘Magento\Store\Model\StoreManagerInterface’);
echo “Current Store ID ============> “.$storeId = $storeManager->getStore()->getId(); // Store Id
\Magento\Framework\Profiler::stop(‘script-optimization-profiler‘);