xhprof hang

服务器装上xhprof后 能得到数据 总是无法显示出图 也装了graphviz 后来将数据打出来保存为 test.dot(digraph call_graph {xxx} 的那一坨) ,然后cat test.dot | dot -Tpng > test.png ,发现生成了图片,但是报fontconfig的错误。 改xhprof_lib/utils/callgraph_utils.php 中的管道配置,将错误刷到文件去,然后sexy的图图就出来了。

function xhprof_generate_image_by_dot($dot_script, $type) {
  $descriptorspec = array(
       // stdin is a pipe that the child will read from
       0 => array("pipe", "r"),
       // stdout is a pipe that the child will write to
       1 => array("pipe", "w"),
       // stderr is a pipe that the child will write to
       //2 => array("pipe", "w"),
       2 => array("file","/home/work/tmp/error-output.txt", "w")
       );

  //$cmd = " dot -T".$type;
  $cmd = " /home/work/graphviz/bin/dot -T".$type;
  //$process = proc_open($cmd, $descriptorspec, $pipes, "/tmp", array());
  $process = proc_open($cmd, $descriptorspec, $pipes, "/home/work/tmp", array());
  if (is_resource($process)) {
    fwrite($pipes[0], $dot_script);
    fclose($pipes[0]);
    $output = stream_get_contents($pipes[1]);
/*
    $err = stream_get_contents($pipes[2]);
    if (!empty($err)) {
      print "failed to execute cmd: \"$cmd\". stderr: `$err'\n";
      exit;
    }
*/
.......................
.......................

你可能感兴趣的:(HP)