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; } /**