footer.php 1.0 KB

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * @package chamilo.profiling
  4. */
  5. /**
  6. * Init
  7. */
  8. $isAjaxRequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
  9. if (extension_loaded('tideways') && !$isAjaxRequest) {
  10. $profiler_namespace = 'chamilolms'; // namespace for your application
  11. $xhprof_data = tideways_disable();
  12. //$xhprof_runs = new XHProfRuns_Default();
  13. //$run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace);
  14. $run_id = uniqid();
  15. file_put_contents(sys_get_temp_dir() . '/' . $run_id . '.' . $profiler_namespace . '.xhprof', serialize($xhprof_data));
  16. // url to the XHProf UI libraries (change the host name and path)
  17. $subDir = substr(__DIR__, strlen(trim($_SERVER['DOCUMENT_ROOT'])));
  18. $profiler_url = sprintf($subDir.'/xhprof_html/index.php?run=%s&source=%s', $run_id, $profiler_namespace);
  19. $mem = round(memory_get_peak_usage()/1024);
  20. echo '<a style="z-index:99; position: absolute;" href="'. $profiler_url .'" target="_blank">Profiler output (Memory: '.$mem.'KB)</a>';
  21. }