index.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // XHProf: A Hierarchical Profiler for PHP
  18. //
  19. // XHProf has two components:
  20. //
  21. // * This module is the UI/reporting component, used
  22. // for viewing results of XHProf runs from a browser.
  23. //
  24. // * Data collection component: This is implemented
  25. // as a PHP extension (XHProf).
  26. //
  27. //
  28. //
  29. // @author(s) Kannan Muthukkaruppan
  30. // Changhao Jiang
  31. //
  32. // by default assume that xhprof_html & xhprof_lib directories
  33. // are at the same level.
  34. $GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib';
  35. include_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php';
  36. // param name, its type, and default value
  37. $params = array('run' => array(XHPROF_STRING_PARAM, ''),
  38. 'wts' => array(XHPROF_STRING_PARAM, ''),
  39. 'symbol' => array(XHPROF_STRING_PARAM, ''),
  40. 'sort' => array(XHPROF_STRING_PARAM, 'wt'), // wall time
  41. 'run1' => array(XHPROF_STRING_PARAM, ''),
  42. 'run2' => array(XHPROF_STRING_PARAM, ''),
  43. 'source' => array(XHPROF_STRING_PARAM, 'xhprof'),
  44. 'all' => array(XHPROF_UINT_PARAM, 0),
  45. );
  46. // pull values of these params, and create named globals for each param
  47. xhprof_param_init($params);
  48. /* reset params to be a array of variable names to values
  49. by the end of this page, param should only contain values that need
  50. to be preserved for the next page. unset all unwanted keys in $params.
  51. */
  52. foreach ($params as $k => $v) {
  53. $params[$k] = $$k;
  54. // unset key from params that are using default values. So URLs aren't
  55. // ridiculously long.
  56. if ($params[$k] == $v[1]) {
  57. unset($params[$k]);
  58. }
  59. }
  60. echo "<html>";
  61. echo "<head><title>XHProf: Hierarchical Profiler Report</title>";
  62. xhprof_include_js_css();
  63. echo "</head>";
  64. echo "<body>";
  65. $vbar = ' class="vbar"';
  66. $vwbar = ' class="vwbar"';
  67. $vwlbar = ' class="vwlbar"';
  68. $vbbar = ' class="vbbar"';
  69. $vrbar = ' class="vrbar"';
  70. $vgbar = ' class="vgbar"';
  71. $xhprof_runs_impl = new XHProfRuns_Default();
  72. displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts,
  73. $symbol, $sort, $run1, $run2);
  74. echo "</body>";
  75. echo "</html>";