Skip to content

Commit

Permalink
Added xhprof around the product export function
Browse files Browse the repository at this point in the history
  • Loading branch information
convenient committed Aug 2, 2015
1 parent 236c34b commit c6342a8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}

/**
Expand Down

0 comments on commit c6342a8

Please sign in to comment.