Newer
Older
Benedikt Wetzel
committed
"cell_type": "markdown",
"source": [
"# Theodolite Analysis - Plotting the Demand Metric\n",
"\n",
"This notebook creates a plot, showing scalability as a function that maps load intensities to the resources required for processing them. It is able to combine multiple such plots in one figure, for example, to compare multiple systems or configurations.\n",
"\n",
"The notebook takes a CSV file for each plot mapping load intensities to minimum required resources, computed by the `demand-metric-plot.ipynb` notebook."
Benedikt Wetzel
committed
"cell_type": "markdown",
"source": [
"First, we need to import some libraries, which are required for creating the plots."
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pandas as pd\n",
"from functools import reduce\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib.ticker import FuncFormatter\n",
"from matplotlib.ticker import MaxNLocator"
Benedikt Wetzel
committed
"cell_type": "markdown",
"We need to specify the directory, where the demand CSV files can be found, and a dictionary that maps a system description (e.g. its name) to the corresponding CSV file (prefix). To use Unicode narrow non-breaking spaces in the description format it as `u\"1000\\u202FmCPU\"`."
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"results_dir = '<path-to>/results'\n",
Benedikt Wetzel
committed
"plot_name = '<plot-name>'\n",
"\n",
"experiments = {\n",
" 'System XYZ': 'exp200',\n",
"}\n"
Benedikt Wetzel
committed
"cell_type": "markdown",
"source": [
"Now, we combie all systems described in `experiments`."
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataframes = [pd.read_csv(os.path.join(results_dir, f'{v}_demand.csv')).set_index('load').rename(columns={\"resources\": k}) for k, v in experiments.items()]\n",
"\n",
"df = reduce(lambda df1,df2: df1.join(df2,how='outer'), dataframes)"
Benedikt Wetzel
committed
"cell_type": "markdown",
"source": [
"We might want to display the mappings before we plot it."
"execution_count": null,
"metadata": {},
"outputs": [],
Benedikt Wetzel
committed
"cell_type": "markdown",
"source": [
"The following code creates a MatPlotLib figure showing the scalability plots for all specified systems. You might want to adjust its styling etc. according to your preferences. Make sure to also set a filename."
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.style.use('ggplot')\n",
"plt.rcParams['pdf.fonttype'] = 42 # TrueType fonts\n",
"plt.rcParams['ps.fonttype'] = 42 # TrueType fonts\n",
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"plt.rcParams['axes.facecolor']='w'\n",
"plt.rcParams['axes.edgecolor']='555555'\n",
"#plt.rcParams['ytick.color']='black'\n",
"plt.rcParams['grid.color']='dddddd'\n",
"plt.rcParams['axes.spines.top']='false'\n",
"plt.rcParams['axes.spines.right']='false'\n",
"plt.rcParams['legend.frameon']='true'\n",
"plt.rcParams['legend.framealpha']='1'\n",
"plt.rcParams['legend.edgecolor']='1'\n",
"plt.rcParams['legend.borderpad']='1'\n",
"\n",
"@FuncFormatter\n",
"def load_formatter(x, pos):\n",
" return f'{(x/1000):.0f}k'\n",
"\n",
"markers = ['s', 'D', 'o', 'v', '^', '<', '>', 'p', 'X']\n",
"\n",
"def splitSerToArr(ser):\n",
" return [ser.index, ser.as_matrix()]\n",
"\n",
"plt.figure()\n",
"#plt.figure(figsize=(4.8, 3.6)) # For other plot sizes\n",
"#ax = df.plot(kind='line', marker='o')\n",
"for i, column in enumerate(df):\n",
" plt.plot(df[column].dropna(), marker=markers[i], label=column)\n",
"plt.legend()\n",
"ax = plt.gca()\n",
"#ax = df.plot(kind='line',x='dim_value', legend=False, use_index=True)\n",
"ax.set_ylabel('number of instances')\n",
"ax.set_xlabel('messages/second')\n",
"ax.set_ylim(ymin=0)\n",
"#ax.set_xlim(xmin=0)\n",
"ax.yaxis.set_major_locator(MaxNLocator(integer=True))\n",
"ax.xaxis.set_major_formatter(FuncFormatter(load_formatter))\n",
"\n",
Benedikt Wetzel
committed
"plt.savefig(results_dir + '/' + plot_name + '.pdf', bbox_inches='tight')"
},
{
"cell_type": "code",
"execution_count": null,
"hash": "e9e076445e1891a25f59b525adcc71b09846b3f9cf034ce4147fc161b19af121"
"display_name": "Python 3.8.10 64-bit ('.venv': venv)",
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
Benedikt Wetzel
committed
"nbconvert_exporter": "python",
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
},
"nbformat": 4,
"nbformat_minor": 2