public function get_run($run_id, $type, &$run_desc)
{
$run_id = $this->db->escape($run_id);
$query = "SELECT * FROM `details` WHERE `id` = '{$run_id}'";
$resultSet = $this->db->query($query);
$data = $this->db->getNextAssoc($resultSet);
// can't find specified data
if (empty($data)) {
return array(null, null);
}
//The Performance data is compressed lightly to avoid max row length
if (!isset($GLOBALS['_xhprof']['serializer']) || strtolower($GLOBALS['_xhprof']['serializer'] == 'php')) {
$contents = unserialize(gzuncompress($data['perfdata']));
} else {
$contents = json_decode(gzuncompress($data['perfdata']), true);
}
//This data isnt' needed for display purposes, there's no point in keeping it in this array
unset($data['perfdata']);
// The same function is called twice when diff'ing runs. In this case we'll populate the global scope with an array
if (is_null($this->run_details)) {
$this->run_details = $data;
} else {
$this->run_details[0] = $this->run_details;
$this->run_details[1] = $data;
}
$run_desc = "XHProf Run (Namespace={$type})";
$this->getRunComparativeData($data['url'], $data['c_url']);
return array($contents, $data);
}
<?php // Setup parameters $key = $_SERVER['argv'][1]; $run = $_SERVER['argv'][2]; $source = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : 'drupal-perf'; // Retrieve run data include_once dirname(__FILE__) . '/xhprof/xhprof_lib/utils/xhprof_lib.php'; include_once dirname(__FILE__) . '/xhprof/xhprof_lib/utils/xhprof_runs.php'; include_once dirname(__FILE__) . '/xhprof/xhprof_lib/display/xhprof.php'; $xhprof_runs_impl = new XHProfRuns_Default(); $run_data = $xhprof_runs_impl->get_run($run, $source, $description); // Save run data ... $data = serialize($run_data); $tmp = tmpfile(); fwrite($tmp, $data); fseek($tmp, 0); // ... and upload. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.lionsad.de/xhprof-kit/hosted/upload.php?key={$key}&run={$run}&source={$source}"); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $tmp); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data)); $result = curl_exec($ch); curl_close($ch); // Then cleanup. fclose($tmp);