[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/xhprof/xhprof_html/ -> callgraph.php (source)

   1  <?php
   2  //  Copyright (c) 2009 Facebook
   3  //
   4  //  Licensed under the Apache License, Version 2.0 (the "License");
   5  //  you may not use this file except in compliance with the License.
   6  //  You may obtain a copy of the License at
   7  //
   8  //      http://www.apache.org/licenses/LICENSE-2.0
   9  //
  10  //  Unless required by applicable law or agreed to in writing, software
  11  //  distributed under the License is distributed on an "AS IS" BASIS,
  12  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13  //  See the License for the specific language governing permissions and
  14  //  limitations under the License.
  15  //
  16  
  17  /**
  18   *
  19   * A callgraph generator for XHProf.
  20   *
  21   * * This file is part of the UI/reporting component,
  22   *   used for viewing results of XHProf runs from a
  23   *   browser.
  24   *
  25   * Modification History:
  26   *  02/15/2008 - cjiang  - The first version of callgraph visualizer
  27   *                         based on Graphviz's DOT tool.
  28   *
  29   * @author Changhao Jiang (cjiang@facebook.com)
  30   */
  31  
  32  // Start moodle modification: moodleize this script.
  33  require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
  34  require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
  35  require_login();
  36  require_capability('moodle/site:config', context_system::instance());
  37  \core\session\manager::write_close();
  38  // End moodle modification.
  39  
  40  // by default assume that xhprof_html & xhprof_lib directories
  41  // are at the same level.
  42  $GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib';
  43  
  44  require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php';
  45  
  46  ini_set('max_execution_time', 100);
  47  
  48  $params = array(// run id param
  49                  'run' => array(XHPROF_STRING_PARAM, ''),
  50  
  51                  // source/namespace/type of run
  52                  'source' => array(XHPROF_STRING_PARAM, 'xhprof'),
  53  
  54                  // the focus function, if it is set, only directly
  55                  // parents/children functions of it will be shown.
  56                  'func' => array(XHPROF_STRING_PARAM, ''),
  57  
  58                  // image type, can be 'jpg', 'gif', 'ps', 'png'
  59                  'type' => array(XHPROF_STRING_PARAM, 'png'),
  60  
  61                  // only functions whose exclusive time over the total time
  62                  // is larger than this threshold will be shown.
  63                  // default is 0.01.
  64                  'threshold' => array(XHPROF_FLOAT_PARAM, 0.01),
  65  
  66                  // whether to show critical_path
  67                  'critical' => array(XHPROF_BOOL_PARAM, true),
  68  
  69                  // first run in diff mode.
  70                  'run1' => array(XHPROF_STRING_PARAM, ''),
  71  
  72                  // second run in diff mode.
  73                  'run2' => array(XHPROF_STRING_PARAM, '')
  74                  );
  75  
  76  // pull values of these params, and create named globals for each param
  77  xhprof_param_init($params);
  78  
  79  // if invalid value specified for threshold, then use the default
  80  if ($threshold < 0 || $threshold > 1) {
  81    $threshold = $params['threshold'][1];
  82  }
  83  
  84  // if invalid value specified for type, use the default
  85  if (!array_key_exists($type, $xhprof_legal_image_types)) {
  86    $type = $params['type'][1]; // default image type.
  87  }
  88  
  89  // Start moodle modification: use own XHProfRuns implementation.
  90  // $xhprof_runs_impl = new XHProfRuns_Default();
  91  $xhprof_runs_impl = new moodle_xhprofrun();
  92  // End moodle modification.
  93  
  94  if (!empty($run)) {
  95    // single run call graph image generation
  96    xhprof_render_image($xhprof_runs_impl, $run, $type,
  97                        $threshold, $func, $source, $critical);
  98  } else {
  99    // diff report call graph image generation
 100    xhprof_render_diff_image($xhprof_runs_impl, $run1, $run2,
 101                             $type, $threshold, $source);
 102  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1