Advertisement
retesere20

tryout-for-plugin-sort-debug-times

Jul 11th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. <div class="title1"><a href="javascript:show_fully();">Functions Timing results</a></div>
  2. <div class="first_row">Total time of page's PHP execution (from the first moment to last moment): <b><?php echo $this->decimal_outputer( _DEBUG_END_TIME_ - _DEBUG_START_TIME_ ); ?></b> seconds </div>
  3.  
  4.  
  5.  
  6. <table class="dft_table"> <script> //document.getElementsByClassName("dft_table")[0].style.visibility = "hidden";</script>
  7. <thead>
  8. <tr class="head_tr">
  9. <th class="triggered_times">trigger<br/>count</th><th class="func_name">Action & Function name</th><th class="complete_length">complete length (seconds)</th>
  10. </tr>
  11. </thead>
  12. <tbody>
  13.  
  14. <?php
  15. $output = '';
  16. $time_total =0;
  17.  
  18. if ($this->standard_way)
  19. {
  20. // ################ Output ################
  21.  
  22. foreach($this->actions as $name=>$array) {
  23. $output .= '<tr>';
  24. $output .='<td>'. count($array) .'</td>';
  25. $output .='<td>'. $name .'</td>';
  26. $action_total = 0;
  27. foreach($array as $randKey=>$array1) {
  28. $mult = 10000;
  29. $action_total += ($array1['end']['time'] *$mult - $array1['start']['time'] *$mult)/$mult;
  30. }
  31. $output .='<td>'. $this->decimal_outputer( $action_total, 4) .'</td>';
  32. $output .='</tr>';
  33.  
  34. $time_total += $action_total;
  35. }
  36. }
  37. else
  38. {
  39.  
  40. // ================== at first, sort =============== //
  41. $sorted_data =[];
  42. $actions_total=0;
  43. foreach($GLOBALS['WPDFT_ARRAY'] as $actionName=>$actionExecutions)
  44. {
  45. $action_total=0;
  46. foreach($actionExecutions as $actionCycleIndex=>$arrayOfFuncs)
  47. {
  48. $functions_total=0;
  49. foreach($arrayOfFuncs as $funcName=>$funcExecutions)
  50. {
  51. $funcion_total = 0;
  52. foreach($funcExecutions as $funcCycleIndex=>$funcBlock) {
  53. $time = $this->decimal_normalizer($funcBlock['end'] - $funcBlock['start']);
  54. $funcion_total += $time;
  55. $sorted_data['actions'][$actionName]['cycles'][$actionCycleIndex]['functions'][$funcName]['cycles'][$funcCycleIndex]['time'] = $time;
  56. }
  57. $functions_total += $funcion_total;
  58. $sorted_data['actions'][$actionName]['cycles'][$actionCycleIndex]['functions'][$funcName]['time'] = $this->decimal_normalizer( $funcion_total );
  59. $this->array_sort_by_column($sorted_data['actions'][$actionName]['cycles'][$actionCycleIndex]['functions'][$funcName]['cycles'], 'time', SORT_DESC );
  60. }
  61. $action_total += $functions_total;
  62. $sorted_data['actions'][$actionName]['cycles'][$actionCycleIndex]['time'] = $this->decimal_normalizer($functions_total) ;
  63. $this->array_sort_by_column($sorted_data['actions'][$actionName]['cycles'][$actionCycleIndex]['functions'], 'time', SORT_DESC );
  64. }
  65. $actions_total += $action_total;
  66. $sorted_data['actions'][$actionName]['time'] = $this->decimal_normalizer($action_total);
  67. $this->array_sort_by_column($sorted_data['actions'][$actionName]['cycles'], 'time', SORT_DESC );
  68. }
  69. $time_total += $actions_total;
  70. $sorted_data['time'] = $this->decimal_normalizer($actions_total);
  71. $this->array_sort_by_column($sorted_data['actions'], 'time', SORT_DESC );
  72.  
  73.  
  74.  
  75. // ################ Output ################
  76.  
  77. $i1=0;
  78. foreach($sorted_data as $key__actions_time=>$time_or_actionsArray) //key: actions|time
  79. {
  80. $i1++;
  81. $i2=0;
  82. if ($key__actions_time!="actions") continue;
  83. foreach($time_or_actionsArray as $actionName=>$time_or_cycles_array_A) //key: only action name
  84. {
  85. foreach($time_or_cycles_array_A as $key__cycles_time=>$time_or_cycleArrays_A) //key: cycles|time
  86. {
  87. if ($key__cycles_time!="cycles") continue;
  88. foreach($time_or_cycleArrays_A as $a_cycleIndex=>$time_or_functions_Arrays) //key: only cycle index
  89. {
  90. foreach($time_or_functions_Arrays as $key__functions_time=>$time_or_functionArrays) //key: functions|time
  91. {
  92. if ($key__functions_time!="functions") continue;
  93. foreach($time_or_functionArrays as $functionName=>$time_or_cycles_array_F) //key: only function name
  94. {
  95. foreach($time_or_cycles_array_F as $key__cycles_time2=>$time_or_cycleArrays_F)//key: cycles|time
  96. {
  97. if ($key__cycles_time2!="cycles") continue;
  98. foreach($time_or_cycleArrays_F as $f_cycleIndex=>$time) //key: only cycle index
  99. {
  100. //$time
  101. }
  102. }
  103.  
  104. $childDiv[] = '<div class="dft_child"> <div class="func_name">'.$functionName .' <span class="func_count">('.count($time_or_cycles_array_F['cycles']).')</span></div> <div class="func_path">'. $GLOBALS['WPDFT_func_paths'][$functionName].'</div></div>';
  105. $childTimes[]= '<div class="dft_child">'. $this->decimal_outputer( $time_or_cycles_array_F['time'], 5) .'</div>';
  106. }
  107. }
  108.  
  109. }
  110. }
  111.  
  112. /*
  113.  
  114. if ( count($array) > 0 && count($array) != $i)
  115. {
  116. $childDiv[] = '<div class="dft_child separator"></div>';
  117. $childTimes[]= '<div class="dft_child separator"></div>';
  118. }
  119. */
  120.  
  121.  
  122. $childDiv_final = implode('', $childDiv);
  123. $childTimes_final = implode('', $childTimes);
  124.  
  125. $output .= '<tr class="dft_tr">';
  126. $output .= '<td>'. count($time_or_cycles_array_A['cycles']) .'</td>';
  127. $output .= '<td>'. $actionName .' <div class="dft_childWrap">'.$childDiv_final.'</div></td>';
  128. $output .= '<td>'. $this->decimal_outputer( $time_or_cycles_array_A['time'], 4) .' <div class="dft_childWrap">'.$childTimes_final.'</div></td>';
  129. $output .= '</tr>';
  130. }
  131.  
  132. }
  133. }
  134. echo $output;
  135. ?>
  136. </tbody>
  137. </table>
  138.  
  139. <div class="first_row">Sum (maximum) time of actions & filters execution (<span class="notic"> This value is just an approximation, because ACTIONS TIME SHOULDN'T BE DIRECTLY SUMED-UP, BECAUSE ONE ACTION MIGHT HAVE BEEN EXECUTED WITHIN ANOTHER ACTION, and, summing up them directly may have caused incorrect (double) summation [So, this value is not reliable, but just an experimental. Instead, use TOTAL TIME of page and try to fix the slowest actions/functions. ... ##</span>): <b id="totalsum_actions"><?php echo $this->decimal_outputer( $time_total ); ?></b> seconds </div>
  140.  
  141. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement