예제 #1
0
 def sort_dict_sqlCount(self, sb, max_row, dic):
     sb.append('<h4>按request执行的SQL数量排序:</h4>')
     s_execute_time = sorted(
         dic.items(),
         cmp=lambda x, y: cmp(x, y),
         key=lambda dic: sum(dic[1][3]) * 1.0 / len(dic[1][3]),
         reverse=True)
     index = 0
     for m in s_execute_time:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         s += '<span style="cursor:pointer;" onclick="request_onclick(this, \'' + m[
             1][0].encode(encode) + '\')">&#43;</span>'
         s += 'avg:' + "%.1f" % (sum(m[1][3]) * 1.0 / len(
             m[1][1])) + ' | sql cost:' + "%.0f" % (
                 sum(m[1][2]) * 1.0 /
                 len(m[1][2])) + 'ms | request cost:' + "%.0f" % (sum(
                     m[1][1]) * 1.0 / len(m[1][1])) + 'ms | count:' + str(
                         len(m[1][1])
                     ) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(
                         m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
     sb.append('<h4>按request的出现频率排序:</h4>')
     s_count = sorted(dic.items(),
                      cmp=lambda x, y: cmp(x, y),
                      key=lambda dic: len(dic[1][1]),
                      reverse=True)
     index = 0
     for m in s_count:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         tmp_avg = sum(m[1][3]) * 1.0 / len(m[1][3])
         tmp_avg_str = str("%.1f" % tmp_avg)
         if tmp_avg > 1000:
             tmp_avg_str = '<b>' + tmp_avg_str + '</b>'
         s += 'avg:' + tmp_avg_str + ' | sql cost:' + "%.0f" % (
             sum(m[1][2]) * 1.0 / len(m[1][2])
         ) + 'ms | request cost:' + "%.0f" % (sum(m[1][1]) * 1.0 / len(
             m[1][1])) + 'ms | count:' + str(len(
                 m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(
                     m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
예제 #2
0
 def sort_dict_executeTime(self, sb, max_row, dic):
     sb.append('<h4>按method的执行时间排序:</h4>')
     s_execute_time = sorted(
         dic.items(),
         cmp=lambda x, y: cmp(x, y),
         key=lambda dic: sum(dic[1][1]) * 1.0 / len(dic[1][1]),
         reverse=True)
     index = 0
     for m in s_execute_time:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         focus_size = sum(m[1][2]) * 1.0 / len(m[1][2])
         focus_size_str = str("%.0f" % focus_size)
         if focus_size > 50:
             focus_size_str = '<b>' + focus_size_str + '</b>'
         s += 'avg:' + "%.0f" % (
             sum(m[1][1]) * 1.0 / len(m[1][1])
         ) + 'ms | return size:' + focus_size_str + ' | count:' + str(
             len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(
                 m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
     sb.append('<h4>按method的出现频率排序:</h4>')
     s_count = sorted(dic.items(),
                      cmp=lambda x, y: cmp(x, y),
                      key=lambda dic: len(dic[1][1]),
                      reverse=True)
     index = 0
     for m in s_count:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         tmp_avg = sum(m[1][1]) * 1.0 / len(m[1][1])
         tmp_avg_str = str("%.0f" % tmp_avg)
         if tmp_avg > 500:
             tmp_avg_str = '<b>' + tmp_avg_str + '</b>'
         focus_size = sum(m[1][2]) * 1.0 / len(m[1][2])
         focus_size_str = str("%.0f" % focus_size)
         if focus_size > 50:
             focus_size_str = '<b>' + focus_size_str + '</b>'
         s += 'avg:' + tmp_avg_str + 'ms | return size:' + focus_size_str + ' | count:' + str(
             len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(
                 m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
예제 #3
0
 def sort_dict_executeTime(self, sb, max_row, dic):
     sb.append("<h4>按method的执行时间排序:</h4>")
     s_execute_time = sorted(
         dic.items(), cmp=lambda x, y: cmp(x, y), key=lambda dic: sum(dic[1][1]) * 1.0 / len(dic[1][1]), reverse=True
     )
     index = 0
     for m in s_execute_time:
         if index >= max_row:
             break
         s = ""
         if index < focus_row_count:
             s += '<div class="focus">'
         focus_size = sum(m[1][2]) * 1.0 / len(m[1][2])
         focus_size_str = str("%.0f" % focus_size)
         if focus_size > 50:
             focus_size_str = "<b>" + focus_size_str + "</b>"
         s += (
             "avg:"
             + "%.0f" % (sum(m[1][1]) * 1.0 / len(m[1][1]))
             + "ms | return size:"
             + focus_size_str
             + " | count:"
             + str(len(m[1][1]))
             + " | rsd:"
             + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1])
             + " | "
             + m[1][0].encode(encode)
         )
         if index < focus_row_count:
             s += "</div>"
         sb.append(s)
         index += 1
     sb.append("<h4>按method的出现频率排序:</h4>")
     s_count = sorted(dic.items(), cmp=lambda x, y: cmp(x, y), key=lambda dic: len(dic[1][1]), reverse=True)
     index = 0
     for m in s_count:
         if index >= max_row:
             break
         s = ""
         if index < focus_row_count:
             s += '<div class="focus">'
         tmp_avg = sum(m[1][1]) * 1.0 / len(m[1][1])
         tmp_avg_str = str("%.0f" % tmp_avg)
         if tmp_avg > 500:
             tmp_avg_str = "<b>" + tmp_avg_str + "</b>"
         focus_size = sum(m[1][2]) * 1.0 / len(m[1][2])
         focus_size_str = str("%.0f" % focus_size)
         if focus_size > 50:
             focus_size_str = "<b>" + focus_size_str + "</b>"
         s += (
             "avg:"
             + tmp_avg_str
             + "ms | return size:"
             + focus_size_str
             + " | count:"
             + str(len(m[1][1]))
             + " | rsd:"
             + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1])
             + " | "
             + m[1][0].encode(encode)
         )
         if index < focus_row_count:
             s += "</div>"
         sb.append(s)
         index += 1
예제 #4
0
 def sort_dict(self, sb, max_row, dic):
     sb.append( '<h4>按SQL的平均执行时间排序:</h4>')
     s_execute_time = sorted(dic.items(), cmp= lambda x,y:cmp(x,y), key=lambda dic: sum(dic[1][1])*1.0/len(dic[1][1]), reverse = True)
     index = 0
     for m in s_execute_time:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         s += 'avg:' + "%.0f" %(sum(m[1][1])*1.0/len(m[1][1])) + 'ms | count:' + str(len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1]) + ' | ' + m[1][2] + ' | ' + m[1][0].encode(encode).replace('<', '&lt;')
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
     sb.append( '<h4>按SQL的出现频率排序:</h4>')
     s_count = sorted(dic.items(), cmp= lambda x,y:cmp(x,y), key=lambda dic: len(dic[1][1]), reverse = True)
     index = 0
     for m in s_count:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         tmp_avg = sum(m[1][1])*1.0/len(m[1][1])
         tmp_avg_str = str("%.0f" %(sum(m[1][1])*1.0/len(m[1][1])))
         if tmp_avg > 50:
             tmp_avg_str = '<b>' + tmp_avg_str + '</b>'
         s += 'avg:' + tmp_avg_str + 'ms | count:' + str(len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1]) + ' | ' + m[1][2] + ' | ' + m[1][0].encode(encode).replace('<', '&lt;')
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
예제 #5
0
 def sort_dict_executeTime(self, sb, max_row, dic):
     sb.append( '<h4>按request的执行时间排序:</h4>')
     s_execute_time = sorted(dic.items(), cmp= lambda x,y:cmp(x,y), key=lambda dic: sum(dic[1][1])*1.0/len(dic[1][1]), reverse = True)
     index = 0
     for m in s_execute_time:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         s += '<span style="cursor:pointer;" onclick="request_onclick(\'' + m[1][0].encode(encode) + '\')">&#43; </span>'
         s += 'avg:' + "%.0f" %(sum(m[1][1])*1.0/len(m[1][1])) + 'ms | sql cost:' + "%.0f" %(sum(m[1][2])*1.0/len(m[1][2])) +  'ms | sql count: ' + "%.1f" %(sum(m[1][3])*1.0/len(m[1][1])) + ' | count:' + str(len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1
     sb.append( '<h4>按request的出现频率排序:</h4>')
     s_count = sorted(dic.items(), cmp= lambda x,y:cmp(x,y), key=lambda dic: len(dic[1][1]), reverse = True)
     index = 0
     for m in s_count:
         if index >= max_row:
             break
         s = ''
         if index < focus_row_count:
             s += '<div class="focus">'
         tmp_avg = sum(m[1][1])*1.0/len(m[1][1])
         tmp_avg_str = str("%.0f" %tmp_avg)
         if tmp_avg > 1000:
             tmp_avg_str = '<b>' + tmp_avg_str + '</b>'
         s += 'avg:' + tmp_avg_str + 'ms | sql cost:' + "%.0f" %(sum(m[1][2])*1.0/len(m[1][2])) +  'ms | sql count: ' + "%.1f" %(sum(m[1][3])*1.0/len(m[1][1])) + ' | count:' + str(len(m[1][1])) + ' | rsd:' + "%.1f" % analyse_qbrm_log.get_rsd(m[1][1]) + ' | ' + m[1][0].encode(encode)
         if index < focus_row_count:
             s += '</div>'
         sb.append(s)
         index += 1