You are here

public function XHProfRunsFile::save_run in XHProf 7

Same name and namespace in other branches
  1. 6 XHProfRunsFile.inc \XHProfRunsFile::save_run()

File

./XHProfRunsFile.inc, line 77
Definition of XHProfRunsFile.

Class

XHProfRunsFile
XHProfRuns_Default is the default implementation of the iXHProfRuns interface for saving/fetching XHProf runs.

Code

public function save_run($xhprof_data, $type, $run_id = NULL) {

  // Use PHP serialize function to store the XHProf's
  // raw profiler data.
  $xhprof_data = serialize($xhprof_data);
  if ($run_id === NULL) {
    $run_id = $this
      ->gen_run_id($type);
  }
  $file_name = $this
    ->file_name($run_id, $type);
  $file = fopen($file_name, 'w');
  if ($file) {
    fwrite($file, $xhprof_data);
    fclose($file);
  }
  else {
    watchdog("xhprof", "Could not open %file_name.", array(
      '%file_name' => $file_name,
    ));
  }

  // echo "Saved run in {$file_name}.\nRun id = {$run_id}.\n";
  return $run_id;
}