prepend_v4.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. register_shutdown_function(
  3. function () {
  4. register_shutdown_function(function () {
  5. $data = tideways_disable();
  6. echo 'Nodes in report: ' . count($data) . "\n";
  7. $name = 'xhprof_report.' . microtime(1) . '.serialized';
  8. echo 'Saving report to ' . $name, "\n";
  9. file_put_contents('/code/' . $name,
  10. serialize($data));
  11. include_once "/utils/callgraph_utils.php";
  12. include_once "/utils/xhprof_lib.php";
  13. include_once "/utils/xhprof_runs.php";
  14. echo "Generating dot script\n";
  15. $threshold = 0;
  16. if (count($data) > 1000) {
  17. $threshold = 0.001;
  18. }
  19. $script = xhprof_generate_dot_script($data, $threshold, null, null, null, null);
  20. echo "Generating dot image\n";
  21. $content = xhprof_generate_image_by_dot($script, 'svg');
  22. echo 'Saving graph to ' . $name . '.svg', "\n";
  23. file_put_contents('/code/' . $name . '.svg',
  24. $content);
  25. });
  26. }
  27. );
  28. tideways_enable(TIDEWAYS_FLAGS_MEMORY | TIDEWAYS_FLAGS_CPU);