prepend_v4.php 1.1 KB

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