From c6342a81e95aedaa4f2f433a18dc0c035774db3c Mon Sep 17 00:00:00 2001 From: convenient Date: Sun, 2 Aug 2015 19:32:45 +0100 Subject: [PATCH] Added xhprof around the product export function --- .../Model/Export/Product.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 1d2b3366d22bd..d12289c624750 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -768,6 +768,17 @@ protected function paginateCollection($page, $pageSize) */ public function export() { + $shouldProfile = false; + if (extension_loaded('xhprof')) { + $xhprofRoot = "/lukerodgers.co.uk/builds/xhprof"; + if (is_dir($xhprofRoot)) { + $shouldProfile = true; + require_once $xhprofRoot . "/xhprof_lib/utils/xhprof_lib.php"; + require_once $xhprofRoot . "/xhprof_lib/utils/xhprof_runs.php"; + xhprof_enable(); + } + } + //Execution time may be very long set_time_limit(0); @@ -794,7 +805,18 @@ public function export() break; } } - return $writer->getContents(); + + $contents = $writer->getContents(); + if ($shouldProfile) { + $uri = date("y-m-d-h-i-s")."-".$_SERVER['SERVER_ADDR']."-".$_SERVER['REQUEST_URI']; + $uri = preg_replace('#[^0-9a-z]+#i', '-', $uri); + $uri = strtolower($uri); + $uri = trim($uri, '-'); + $xhprof_data = xhprof_disable(); + $xhprof_runs = new \XHProfRuns_Default(); + $xhprof_runs->save_run($xhprof_data, $uri); + } + return $contents; } /**