Skip to content
Snippets Groups Projects
Commit dbf30e62 authored by Pierre Augier's avatar Pierre Augier
Browse files

Add fluidfft/microbench/make_fig_bar.py

parent 06b841b9
No related branches found
No related tags found
No related merge requests found
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
from fluiddyn.output.rcparams import set_rcparams
set_rcparams(fontsize=14, for_article=True, for_beamer=False)
here = os.path.abspath(os.path.dirname(__file__))
here_tmp = os.path.join(here, '../tmp')
if not os.path.exists(here_tmp):
os.mkdir(here_tmp)
keys_outplace = (
'fortran',
'numpy',
'pythran',
'pythran\nloops',
'numba\nloops')
times_outplace = np.array([22.1, 66.6, 36.2, 19.1, 24.4,])
left = [0, 1, 2, 3, 4]
colors = ('w', 'y', 'c', 'c', 'b')
fig, axes = plt.subplots(2, figsize=(8, 4))
ax = axes[0]
ax.bar(left, height=times_outplace, color=colors, edgecolor='k', yerr=2)
ax.set_xticks([])
ax.set_xticklabels([])
ax.set_ylabel('time (ms)')
ax.set_title('outplace (with memory allocation)')
y = 48
for x, s in zip(left, keys_outplace):
ax.text(x, y, s, rotation=20,
horizontalalignment='center',
verticalalignment='center')
keys_inplace = (
'fortran',
'numpy',
'pythran',
'pythran\nloops',
'numba\nloops')
colors = ('w', 'y', 'c', 'c', 'b')
times_inplace = np.array([9., 54.2, 18.3, 8.5, 14.6,])
left = np.arange(len(times_inplace)) + len(times_outplace)
ax = axes[1]
ax.bar(left, height=times_inplace, color=colors, edgecolor='k', yerr=2)
ax.set_xticks([])
ax.set_xticklabels([])
ax.set_ylabel('time (ms)')
ax.set_title('inplace')
y = 40
for x, s in zip(left, keys_inplace):
ax.text(x, y, s, rotation=20,
horizontalalignment='center',
verticalalignment='center')
fig.tight_layout()
path_fig = os.path.join(here_tmp, 'fig_microbench.pdf')
if 'save' in sys.argv:
fig.savefig(path_fig, dpi=800)
else:
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment