Permalink
Browse files

Add readme, rendering profiles to file

Added first version of readme.
Added helper method which saves profiler output as html file
it is usefull when you want to profile cli scripts.
  • Loading branch information...
1 parent 96438c5 commit 4756ebf2b9e85778a225f3fc9f4b6b74de7dd2ac @tmotyl tmotyl committed Dec 18, 2012
Showing with 43 additions and 0 deletions.
  1. +22 −0 Readme.md
  2. +21 −0 app/code/community/Aoe/Profiler/Helper/Data.php
View
@@ -0,0 +1,22 @@
+++++++++++++++++++++++++
+Magento Profiler
+++++++++++++++++++++++++
+
+http://www.fabrizio-branca.de/magento-profiler.html
+
+
+Profile cli scripts
+=========================
+
+To profile shell scripts like Mage_Shell_Compiler change code at the end of the file to:
+
+```php
+$_GET['profile'] = true;
+require_once '../app/Mage.php';
+Varien_Profiler::start("wrapper");
+$shell = new Mage_Shell_Compiler();
+$shell->run();
+Varien_Profiler::stop("wrapper");
+Mage::helper('aoe_profiler')->renderProfilerOutputToFile();
+```
+You will find html page with rendered profiler output in var/log/profile<date>.html
@@ -35,4 +35,25 @@ public function getSkinFileContent($file) {
return $content;
}
+ /**
+ * Renders Magento page with profiler output to file
+ * Useful when profiling cli scripts
+ */
+ public function renderProfilerOutputToFile() {
+
+ $layout = Mage::app()->getLayout();
+ $layout->getUpdate()->addHandle(array('default', 'page_one_column'));
+ $layout->getUpdate()->load();
+ $layout->generateXml()->generateBlocks();
+
+ $root = $layout->getBlock('root');
+ $template = "page/1column.phtml";
+ $root->setTemplate($template);
+ $block = $layout->createBlock('core/profiler', 'profiler');
+ /** @var $content Mage_Core_Block_Text_List */
+ $content = $root->getChild('content');
+ $content->append($block, 'profiler_output');
+ $content = $root->toHtml();
+ file_put_contents(Mage::getBaseDir('var') . DS . 'log' . DS . "profile".time().".html", $content);
+ }
}

0 comments on commit 4756ebf

Please sign in to comment.