コード例 #1
0
ファイル: analyze.py プロジェクト: ziq211/hue
def summary(profile):
    summary = profile.find_by_name('Summary')
    execution_profile = profile.find_by_name('Execution Profile')
    counter_map = summary.counter_map()
    counter_map_execution_profile = execution_profile.counter_map()
    host_list = models.host_by_metric(profile, 'PeakMemoryUsage', exprs=[max])
    host_list = sorted(host_list, key=lambda x: x[1], reverse=True)
    peak_memory = models.TCounter(
        value=host_list[0][1], unit=3) if host_list else models.TCounter(
            value=0, unit=3)  # The value is not always present
    return [{
        'key': 'PlanningTime',
        'value': counter_map['PlanningTime'].value,
        'unit': counter_map['PlanningTime'].unit
    }, {
        'key': 'RemoteFragmentsStarted',
        'value': counter_map['RemoteFragmentsStarted'].value,
        'unit': counter_map['RemoteFragmentsStarted'].unit
    }, {
        'key': 'TotalTime',
        'value': counter_map_execution_profile['TotalTime'].value,
        'unit': counter_map_execution_profile['TotalTime'].unit
    }, {
        'key': 'PeakMemoryUsage',
        'value': peak_memory.value,
        'unit': peak_memory.unit
    }]
コード例 #2
0
def heatmap_by_host(profile, counter_name):
  rows = models.host_by_metric(profile,
                               counter_name,
                               exprs=[max, sum])
  # Modify the data to contain the relative data as well
  sum_sum = 0
  max_max = 0
  if (rows):
    sum_sum = float(sum([v[2] for v in rows]))
    max_max = float(max([v[1] for v in rows]))

  result = []
  for r in rows:
    result.append([r[0], float(r[1]), float(r[2]),
        float(r[1]) / float(max_max) if float(max_max) != 0 else 0,
        float(r[2]) / float(sum_sum) if float(sum_sum) != 0 else 0,
        rows.unit])
  return { 'data': result, 'max': max_max, 'unit': rows.unit }