Exemple #1
0
    # v = brutality[k]
    line = "{k:<10} & {v:.1f}\% \\\ \hline".format(k=k, v=v)
    print(line)
  print()

def print_double(data1, data2):
  sorted_data1 = sorted_dict(data1)
  sorted_data2 = sorted_dict(data2)
  iterator = zip(sorted_data1, sorted_data2)
  for (k1,v1), (k2,v2) in iterator:
    line = r"{k1:<10} & {v1:>5.1f}\% & {k2:<10} & {v2:>5.1f}\% \\ \hline".format(**locals())
    print(line)

single = {}
for name in os.listdir(path_single):
  hpc = csv2dict(path_single+name)
  inps = hpc['instructions'] / hpc['cycles']
  single[name] = inps

summary = 0
double = {}
print("~           &", " &".join(sorted(single)), "\\\\")
for bg in sorted(single):
  print("{:12}".format(bg), end='')
  for fg in sorted(single):
    hpc = csv2dict(path_double+bg+'/'+fg)
    inps = hpc['instructions'] / hpc['cycles']
    ratio = inps/single[fg]
    double[bg,fg] = ratio
    percents = (1 - ratio)* 100
    # if percents < 0:
Exemple #2
0
def perfbars(files, annotations=[], thr=0.01, show=False, output=None, title=None, quiet=False, key_order=None):
  p.figure()
  num = len(files)
  assert num > 0, "please provide at least one path"

  if not annotations:
    annotations = [basename(f) for f in files]

  data = [csv2dict(f) for f in files]
  bars = [[] for _ in data]
  labels = []

  if key_order:
    print("WITH KEY_ORDER THRESHOLD IS ALWAYS 0")
    thr = 0.0
  if not key_order:
    key_order = sorted(data[0])
  if 'cycles' in key_order:
    key_order.remove('cycles')

  for k in reversed(key_order):
    values = []
    for datum, bar in zip(data, bars):
      values += [ datum[k] / datum['cycles'] ]
    if list(filter(lambda x: x>thr, values)):
      labels += [k]
      for bar, v in zip(bars, values):
        bar += [v]
    else:
      if not quiet: print("excluding", k)
  for b in bars:
    if not quiet: print(b, labels)

  ind = p.arange(len(labels))
  print("ind", ind)

  if title:
    title=title.replace(r"\n", "\n")
    p.title(title, weight="semibold")
  ## title
  # title(" | ".join(map(basename, fnames)))

  ## bars
  for i, bar in enumerate(bars):
    p.barh(ind+BARWIDTH*(num-2*i-2)/(2*num), bar, height=BARWIDTH/num, label=annotations[i],
    #**styles[i]) #
    color=cm.Greys_r((i+0.4)/len(bars)*0.8))
    #color=cm.gist_ncar(1-1/num*i), hatch=hatches[i], alpha=0.7)

  ## reverse legend
  # handles, labels = gca().get_legend_handles_labels()
  # legend(handles[::-1], labels[::-1], loc='best')
  p.legend(loc="best")

  ## grid
  p.grid(lw=1)

  ## xaxis
  xaxis = p.gca().xaxis
  # xaxis.set_major_formatter(to_percent)
  # xaxis.set_major_locator(MaxNLocator(nbins=4, prune='upper'))
  p.xlabel("Avg. number of events per CPU cycle")
  # xlim(0,1)

  ## set aspect
  # g = gca()
  # g.set_aspect(0.6)

  ## yaxis
  p.yticks(enum_(labels), labels)
  p.ylim(-0.5, len(labels)-0.5)

  p.tight_layout(pad=0.5)
  if output:
    p.savefig(output)
  if show:
    p.show()