thesis version
This commit is contained in:
113
rtbenchmarks/plot_basic
Executable file
113
rtbenchmarks/plot_basic
Executable file
@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, sys
|
||||
sys.path.append(os.path.abspath(os.path.dirname(os.path.abspath(__file__))+"/../scripts"))
|
||||
|
||||
import fileinput
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
|
||||
show = len(sys.argv) > 1 and sys.argv[1] == 'show'
|
||||
if not show:
|
||||
mpl.use('pgf')
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.lines as lines
|
||||
from common import set_size, config_plt, get_colors, fix_log_rects
|
||||
|
||||
config_plt()
|
||||
|
||||
|
||||
def loadData(fn):
|
||||
content = []
|
||||
|
||||
with open(fn) as f:
|
||||
content = f.readlines()
|
||||
|
||||
values = {}
|
||||
for line in content:
|
||||
n, method, sample, ncores, strtime = [x for x in line.split(':')]
|
||||
time = float(strtime)
|
||||
if method != "seq":
|
||||
time = time/float(ncores)
|
||||
if not n in values:
|
||||
values[n] = []
|
||||
values[n].append(time);
|
||||
|
||||
return values
|
||||
|
||||
|
||||
def figSize(title, xlabel, xticks, output, datasrcs, error=False):
|
||||
fig = plt.figure()
|
||||
|
||||
plt.title(title)
|
||||
plt.xlabel(xlabel)
|
||||
plt.ylabel(u"temps (s)")
|
||||
plt.xticks(xticks)
|
||||
plt.xscale('log')
|
||||
plt.yscale('log')
|
||||
|
||||
nd = len(datasrcs)
|
||||
|
||||
width = 3.5
|
||||
pos = .5-.5*nd
|
||||
for f, label in datasrcs:
|
||||
values = loadData(f)
|
||||
barcolor, errcolor = get_colors(['seq', 'omp', 'gen_omp', 'gen_thread'], label)
|
||||
|
||||
for k, a in values.items():
|
||||
x = int(k)
|
||||
m = np.mean(a)
|
||||
s = 2.5758 * np.std(a) / np.sqrt(len(a)) # confiance 99 %
|
||||
|
||||
x = x * ((20+width)/(20-width))**pos
|
||||
|
||||
p = np.log10(x)
|
||||
lwidth = width * 10**(p-1)
|
||||
|
||||
bar = plt.bar(x, m, width=lwidth, color=barcolor, label=label)
|
||||
fix_log_rects(bar, 1e-4)
|
||||
|
||||
if error:
|
||||
plt.errorbar(x, m, s, elinewidth=1.5, capsize=2, ecolor=errcolor)
|
||||
label=''
|
||||
|
||||
pos = pos + 1
|
||||
|
||||
plt.legend(bbox_to_anchor=(.38, 1))
|
||||
|
||||
fig.set_size_inches(set_size(455.24408, .8))
|
||||
if not show:
|
||||
plt.savefig(output, format='pdf', bbox_inches='tight')
|
||||
return plt
|
||||
|
||||
|
||||
# script
|
||||
plts = []
|
||||
|
||||
plt = figSize(u"", u"taille des données", [1e2, 1e3, 1e4, 1e5, 1e6, 1e7],
|
||||
"plots/rt_seq.pdf", [
|
||||
['data_basic/rt_seq_seq', 'seq'],
|
||||
['data_basic/rt_seq_gen_omp', 'gen_omp'],
|
||||
['data_basic/rt_seq_gen_thread', 'gen_thread'],
|
||||
],
|
||||
error=True
|
||||
)
|
||||
plts.append(plt)
|
||||
|
||||
for cores in [1, 2, 4, 6, 8, 10, 12, 14, 16, 18]:
|
||||
plt = figSize(u"", u"taille des données", [1e2, 1e3, 1e4, 1e5, 1e6, 1e7],
|
||||
"plots/rt_par_"+str(cores)+".pdf", [
|
||||
['data_basic/rt_size_'+str(cores)+'_seq', 'seq'],
|
||||
['data_basic/rt_size_'+str(cores)+'_omp', 'omp'],
|
||||
['data_basic/rt_size_'+str(cores)+'_gen_omp', 'gen_omp'],
|
||||
['data_basic/rt_size_'+str(cores)+'_gen_thread', 'gen_thread'],
|
||||
],
|
||||
error=True
|
||||
)
|
||||
plts.append(plt)
|
||||
|
||||
if show:
|
||||
for plt in plts:
|
||||
plt.show()
|
Reference in New Issue
Block a user