Skip to content

Commit c6342a8

Browse files
committed
Added xhprof around the product export function
1 parent 236c34b commit c6342a8

File tree

1 file changed

+23
-1
lines changed
  • app/code/Magento/CatalogImportExport/Model/Export

1 file changed

+23
-1
lines changed

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,17 @@ protected function paginateCollection($page, $pageSize)
768768
*/
769769
public function export()
770770
{
771+
$shouldProfile = false;
772+
if (extension_loaded('xhprof')) {
773+
$xhprofRoot = "/lukerodgers.co.uk/builds/xhprof";
774+
if (is_dir($xhprofRoot)) {
775+
$shouldProfile = true;
776+
require_once $xhprofRoot . "/xhprof_lib/utils/xhprof_lib.php";
777+
require_once $xhprofRoot . "/xhprof_lib/utils/xhprof_runs.php";
778+
xhprof_enable();
779+
}
780+
}
781+
771782
//Execution time may be very long
772783
set_time_limit(0);
773784

@@ -794,7 +805,18 @@ public function export()
794805
break;
795806
}
796807
}
797-
return $writer->getContents();
808+
809+
$contents = $writer->getContents();
810+
if ($shouldProfile) {
811+
$uri = date("y-m-d-h-i-s")."-".$_SERVER['SERVER_ADDR']."-".$_SERVER['REQUEST_URI'];
812+
$uri = preg_replace('#[^0-9a-z]+#i', '-', $uri);
813+
$uri = strtolower($uri);
814+
$uri = trim($uri, '-');
815+
$xhprof_data = xhprof_disable();
816+
$xhprof_runs = new \XHProfRuns_Default();
817+
$xhprof_runs->save_run($xhprof_data, $uri);
818+
}
819+
return $contents;
798820
}
799821

800822
/**

0 commit comments

Comments
 (0)