using xhprof in drupal 6 to monitor a cron task and display in the XHProf runs page I'm trying to profile a specific cron task in drupal 6 to check the function calls made and what consumes the maximum time and decided to use the XHProf module  which I've never used before. I've got the module successfully installed and able to get the page loads profiled and listed in admin/reports/xhprof.

But to get my cron task to be profiled and listed in it I'm pretty clueless and tried out a few things from what I could gather from PHP.net but beyond coding 

xhprof_enable();
echo "&lt;h2&gt;ENABLED&lt;/h2&gt;";
// the code block I wish to profile
$xhprof_data = xhprof_disable();
echo "&lt;pre&gt;";
print_r($xhprof_data);
echo "&lt;/pre&gt;";  


by checking the internet. The $xhprof_data does contain the necessary info array. But I'm not able to get the slightest hint of how this data that's printed could be formatted and displayed like the page loads which get profiled out of the box. Any help on this is greatly appreciated.
I haven't used the D6 version before but rummaging through the code I think something like this will work:

1st bit (taken from xhprof_shutdown_xhprof())

$namespace = variable_get('site_name', '');  // namespace for your application
$xhprof_data = xhprof_disable();

// Path to save file. Leave empty to use a default
$xhprof_data['path'] = isset($_GET['q'])?$_GET['q'] : ''; 
$class = variable_get('xhprof_default_class', 'XHProfRunsFile');
$xhprof_runs = new $class();
$run_id = $xhprof_runs-&gt;save_run($xhprof_data, $namespace);


2nd bit (taken from xhprof_display_page())

drupal_add_css(drupal_get_path('module', 'xhprof') . '/xhprof.css');
$html = xhprof_display_run(array($run_id), NULL);

// Do what you need to with $html to get it out to the screen